如果没有,我该怎么用?
答案 0 :(得分:0)
好吧,如果您对“ week”的定义与SQL Server的定义相同,则可以使用:
select (datepart(week, date_col) + 3 / 4) as four_week_period
如果要在一年的第一天开始一周,则:
select (datediff(day, datefromparts(year(date_col), 1, 1), date_col) + 27 / 28)
答案 1 :(得分:0)
您也可以从此过滤:
SELECT
ROW_NUMBER() OVER (ORDER BY date) Period_Id,
date as FirstWeekDay,
dateAdd(day, 28, date) as LastWeekDay --divide the days into periods of 4 weeks.
FROM table
WHERE DATENAME(dw, date) IN ('Monday')
ORDER BY date