Discussion Locked

Date range search SQL query in MS SQL Se

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am looking for the SQL query for performing search by using a condition in which I have "Date" as a column name and datatype is "datetime" in the database.

My search criteria is date range ("from" date and "to" date).

5 replies

by john_wills

SELECT *
FROM TheTable
WHERE Date BETWEEN #2001.03.04# AND #2002.03.03#
There may be an oddity in your version of SQL, but something very like this should work.

by andrew

The above answer is correct, except the syntax is Access specific. Use the following syntax for SQL Server:

Select Date
From Table
Where Date Between '1/1/2001' and '1/1/2002'

This discussion is closed to new replies.