Q&A for people interested in the history and origins of science and mathematics
SET DATEFIRST 1; DECLARE @sDate date DECLARE @eDate date; SET @sDate = '2018-01-01'; SET @eDate = '2025-12-31'; ;with GetDates As ( Select DATEADD(day, -1, @sDate) as TheDate UNION ALL Select DATEADD(day, 1, TheDate) as TheDate from GetDates where TheDate < @eDate ) Select DATEPART(iso_week, TheDate) as WeekOfYear, TheDate from GetDates option (maxrecursion 0);