Home > DeveloperSection > Forums > How to select data from date range between two dates using SQL
Kate Smith
Kate Smith

Total Post:24

Points:168
Posted on    October-16-2013 6:52 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 4052  View(s)
Rate this:

I have a table with Product_sales name and it holds like below

Product_ID         Sold_by                                Qty           From_date           To_date

     1001                   21                                       17             2013-02-05       2013-03-17

     1002                   78                                        4               2013-02-06       2013-04-11

     1003                   18                                       19              2013-01-05       2013-03-30

Now what is the query if I want to select sales data between two dates from a date range ? (Like Select sales data from 2013-01-03 to 2013-01-09)



Andrew Deniel
Andrew Deniel

Total Post:29

Points:203
Posted on    October-16-2013 7:38 AM

You should use below line of query to get the data from between two dates

SELECT * FROM Product_sales WHERE From_date >= '2013-02-05' AND To_date <= '2013-04-11'

Don't want to miss updates? Please click the below button!

Follow MindStick