SQLServer 获取第几周开始日期

不多说直接上code

DECLARE @CurrDay DATETIME=GETDATE()
--SET @CurrDay=CAST(('2013-01-10')AS DATETIME)
--SET @CurrDay=CAST(('2012-01-10')AS DATETIME) DECLARE @CurrWK INT=DATEPART(wk,@CurrDay) DECLARE @YearFisrtDay DATETIME=CAST((DATENAME(yy,@CurrDay)+'-01-01') AS DATETIME)
PRINT @YearFisrtDay
--这一年的第一天是星期几
DECLARE @YearFistWK INT=DATEPART(dw,@YearFisrtDay)
PRINT @YearFistWK --总多少天 -第一天是属于的周
PRINT DATEADD(DAY,(@CurrWK-1)*7-@YearFistWK+1,@YearFisrtDay)

  

上一篇:secureCRT免密码登陆Linux


下一篇:Unity制作游戏中的场景