Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Need date for Monday from Year and Week

Author  Topic 

vmon
Yak Posting Veteran

63 Posts

Posted - 2004-07-08 : 12:20:48
I need to output the Date for a year and week number. I am given 2004-28 which is week 28 of 2004. How can I turn that into the mm/dd/yyyy for the Monday of that week and year. I have tried datepart and getdate but they need a date and all I have is year and week.

Thanks in advance,
vmon

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-07-08 : 13:19:37
Declare @curWeek int
Set @curWeek = 28


Select
mondayOfWeek = dateadd(d, (@curWeek-1)*7, thisYear) - datepart(dw,thisYear) + 1,
checkWeekNum = datepart(ww,dateadd(d, (@curWeek-1)*7, thisYear) - datepart(dw,thisYear) + 1)
From
(
Select thisYear = convert(Datetime,'1/1/' + convert(nvarchar,year(getdate())))
) as A



Corey
Go to Top of Page
   

- Advertisement -