Here is a T-SQL snippet that does what you want. In SQL 7, you could use this in a stored procedure. In SQL 2000, it could become a UDF. Hopefully, someone can suggest something easier.
This example determines for the start and end dates of week 20.
declare @wk int, @dt smalldatetime, @dw int
set @wk=20
set @dt=dateadd(week,@wk,'01/01/' + str(year(getdate())))
Set @dw=datepart(dw, @dt)
Select dateadd(d,1-@dw,@dt) AS StartDate, dateadd(d,7-@dw,@dt) As EndDate
This code depends on January 1 being in the first week. If it is not you'll need to do some adjusting. Terry
X-) "Life would be easier if I had the source code." -Anonymous
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.