HOW TO SELECT DATA FROM DATE RANGE BETWEEN TWO DATES USING SQL

Kate Smith

Total Post:24

Points:168
Posted by  Kate Smith
 6272  View(s)
Ratings:
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)

  1. Andrew Deniel

    Post:29

    Points:203
    Re: How to select data from date range between two dates using SQL

    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'

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!