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
 SQL Server Development (2000)
 Getting Dates based on Year and Weeknumber

Author  Topic 

astro26
Starting Member

1 Post

Posted - 2009-02-05 : 07:39:43
Hi all,

I need to do the following:
I enter the Year and Week number as input parameters and as output I need the Start and End Dates.

Eg. If the input parameters are 2009 (year) and 6 (week), the output must be 01/02/2009 and 07/02/2009.

How can this be done. Any help greatly appreciated :)

Thanks and Regards,
Hari.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-05 : 11:48:10
[code]
DECLARE @Year int,@WeekNo int

SELECT @Year=2009,@WeekNo=4
SELECT DATEADD(wk,@WeekNo-1,DATEADD(yy,@Year-1900,0)) AS StartDate,DATEADD(wk,@WeekNo,DATEADD(yy,@Year-1900,0))-1 AS EndDate

[/code]
Go to Top of Page
   

- Advertisement -