jaymin sathavara

jaymin sathavara

  • NA
  • 31
  • 1.9k

How to Get all Dates Between Two Dates in SQL

Jul 18 2022 5:35 AM

I want to display all the dates between two dates for a particular record

Table.

JWDID FromDate ToDate Quantity
100 2022-06-01 2022-06-05 1000
101 2022-06-03 2022-06-03 1500
102 2022-06-29 2022-07-03 1800

I need to output all dates with Quantity between fromDate & To Date.

Where FromDate >= '2022-06-01' AND ToDate <= '2022-06-30'

Expected output : 

JWDID Date FromDate ToDate Quantity
100 2022-06-01 2022-06-01 2022-06-05 1000
100 2022-06-02 2022-06-01 2022-06-05 1000
100 2022-06-03 2022-06-01 2022-06-05 1000
100 2022-06-04 2022-06-01 2022-06-05 1000
100 2022-06-05 2022-06-01 2022-06-05 1000
101 2022-06-03 2022-06-03 2022-06-03 1500
         

guide me to write a query

 


Answers (2)