Example of Date Range Selection in MSSQL
Example of Date Range Selection: WITH q AS ( SELECT 1 AS num UNION ALL SELECT num + 1 FROM q WHERE num < 10 ) SELECT DATEADD(DAY,0,cast(cast(DATEADD(DAY,-num,SYSDATETIME()) as date) as datetime)) FROM q Simple version of the example of selecting a range of numbers: