Solved

sql server - select a value between to specific dates

Posted on 2013-01-21
2
296 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
2 Comments
 
LVL 8

Accepted Solution

by:
virtuadept earned 500 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 69

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CONVERT date time to a different time zone. 2 44
In or Between 2 44
SQL Exceptions 3 37
Removing SQL Replication from Microsoft SQL Server 2008 R2 2 17
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now