By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
--Source: https://sqldusty.com/2015/05/15/generate-a-date-table-via-common-table-expression-cte/
;with dates ([Date]) as (
Select convert(date,'2021-12-01') as [Date] -- Put the start date here
union all
Select dateadd(day, 1, [Date])
from dates
where [Date] < '2021-12-26' -- Put the end date here
)
select [Date]
from dates
option (maxrecursion 32767) -- Don't forget to use the maxrecursion option!
Date |
---|
2021-12-01 |
2021-12-02 |
2021-12-03 |
2021-12-04 |
2021-12-05 |
2021-12-06 |
2021-12-07 |
2021-12-08 |
2021-12-09 |
2021-12-10 |
2021-12-11 |
2021-12-12 |
2021-12-13 |
2021-12-14 |
2021-12-15 |
2021-12-16 |
2021-12-17 |
2021-12-18 |
2021-12-19 |
2021-12-20 |
2021-12-21 |
2021-12-22 |
2021-12-23 |
2021-12-24 |
2021-12-25 |
2021-12-26 |