显示周数,如‘2019年1月第2周’

--显示周数,如‘2019年1月第2周’
update a set szs = cast(datepart(year,a.dweekday) as varchar(4))+''+
cast(datepart(mm,a.dweekday) as varchar(4))+'月第'+
rtrim(case when datepart(dw,dateadd(dd,-day(a.dweekday),a.dweekday))>=5 then 0 else 1 end+
case when datepart (dw,dateadd(dd,-1,a.dweekday))>=5 then 
ceiling(day(dateadd(dd,-7,a.dweekday))/7.0) else 
ceiling(day(a.dweekday)/7.0) end)+'' from weekly a where a.id = '${targetID}'

 

posted @ 2019-07-05 11:18  RainHouse  阅读(181)  评论(0编辑  收藏  举报