[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

sql server - select a value between to specific dates

Posted on 2013-01-21
2
Medium Priority
?
320 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 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
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…
Loops Section Overview

825 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