Пример выбора диапазона дат в MSSQL
Пример выбора диапазона дат:
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