Get the date of a given day in a given week...
Posted
by Sean.C
on Stack Overflow
See other posts from Stack Overflow
or by Sean.C
Published on 2009-10-14T00:26:21Z
Indexed on
2010/03/17
1:31 UTC
Read the original article
Hit count: 429
tsql
|sql-server-2005
i need to start at a year-month and work out what the date it is in a given week, on a given day within that week..
i.e
year: 2009 month: 10 week: 5 day-number: 0
would return 2009-10-25 00:00:00 which is a sunday. Notice week 5, there is no day 0 in week 5 in 2009-10 as the sunday in that logical week is 2009-11-01 00:00:00... so week 5 would always return the last possible date for the given day in the given month..
if you havn't guessed already i'm messing with the c struct TIME_ZONE_INFORMATION (link text) which is pretty crazy if i'm fair...
Date math and SQL are something to be admired, sadly its something i have never really dug deep into beyond stripping times. Any help would be greatly appriciated.
PS: mssql 2005 btw..
© Stack Overflow or respective owner