drop function dbo.weekXMonday
go
create function dbo.weekXMonday(@year int, @weekno int)
returns datetime as
begin
declare @d datetime
set @d=dateadd(yy, @year-1900, 0)
return (dateadd(wk,@weekno-1,@d)-((datepart(dw,@d-2)+@@datefirst)%7))
return @d
end
GO
select dbo.weekXMonday(2009,34)
select dbo.weekXMonday(2010,34)
|