我个人可用的方法是根据数据库来判断的,我这边SQLSERVER的,可自行判断跨年周次
可配合使用
--公式
可使用年份进行拼接,SQL("","")
--语法(语法对应修改周次从周一至周日为一周,对应写好的还有一个mysql的,)
SELECT
CASE WHEN DATEPART(WEEKDAY,GETDATE()) IN (2,3,4,5,6,7) AND DATEPART(WEEKDAY,DATENAME(YEAR,GETDATE())+'-01-01')=1 THEN DATEPART(WEEK,GETDATE())+1
WHEN DATEPART(WEEKDAY,GETDATE())=1 AND DATEPART(WEEKDAY,DATENAME(YEAR,GETDATE())+'-01-01')=1 THEN DATEPART(WEEK,GETDATE())
WHEN DATEPART(WEEKDAY,GETDATE()) IN (2,3,4,5,6,7) THEN DATEPART(WEEK,GETDATE())
ELSE DATEPART(WEEK,GETDATE())-1 END AS WEEK