DECLARE @minDateTime AS DATETIME = GETDATE()-1;
DECLARE @maxDateTime AS DATETIME = GETDATE();
WITH Dates_CTE AS (
SELECT
@minDateTime AS Dates
UNION ALL
SELECT
DATEADD(hh, 1, Dates)
FROM
Dates_CTE
WHERE
Dates < @maxDateTime
)
SELECT
TOP(24) CONVERT(
VARCHAR(2),
Dates,
108
) + ':00 - ' + CONVERT(
varchar(2),
DATEADD(HOUR, 1, Dates),
108
) + ':00' AS 'HourRange'
FROM
Dates_CTE
My WordPress Blog
İlk Yorumu Siz Yapın