create table test (yyyymm int, weekNum int)
Insert into test values(201402,6), (201401,1)
select
--Dateadd(day, ((datepart(weekday,'1/1/2014')-7)+ weeknum*7)-1,
Dateadd(day, ((datepart(weekday, dateadd(year, Datediff(year, 0, Cast(cast(yyyymm as varchar(6))+'01' as datetime)),0 ) )-7)+ weeknum*7)-1,
Dateadd(year, datediff(year, 0, Cast(cast(yyyymm as varchar(6))+'01' as datetime)),0 ))
from test
drop table test
No comments:
Post a Comment