Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql server - select a value between to specific dates

Posted on 2013-01-21
2
Medium Priority
?
318 Views
Last Modified: 2013-01-21
Hi

Im wanting to do a select query that selects a value from a table where its created date is in the range of 2 specific dates (date from & date to)

Thanks
0
Comment
Question by:razza_b
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
virtuadept earned 2000 total points
ID: 38801399
SELECT col_with_value
FROM the_table
WHERE col_create_date >= '1/1/2013'
AND col_create_date <= '2/1/2013'

you could use @variables instead of hard coded dates. Depends on what you are calling this from. Also post the table def and we can be more helpful.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 38801650
you can also use BETWEEN

SELECT col_with_value
FROM the_table
WHERE col_create_date BETWEEN '1/1/2013' AND '2/1/2013'
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question