9

Is there a way to generate dates between date ranges. After looking on SO I found out there is a way to use CTE, another option is to use Union All from 0 to 9. Is there an inbuilt function which I can use to generate dates between date range?

We are using MySQL 8.0.

j10
  • 309
  • 1
  • 8
  • 16

1 Answers1

22

I tried this solution :

WITH recursive Date_Ranges AS (
    select '2018-11-30' as Date
   union all
   select Date + interval 1 day
   from Date_Ranges
   where Date < '2018-12-31')
select * from Date_Ranges;
Kondybas
  • 4,800
  • 19
  • 16
preeti tank
  • 346
  • 2
  • 4