Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate month number based on week no
Message
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Calculate month number based on week no
Miscellaneous
Thread ID:
01653240
Message ID:
01653240
Views:
60
Hi,

In SQL Server database table I have two columns, WEEK_NO, and MONTH (both Integers). I have the entry in the WEEK_NO, Week Number in this year. Does SQL have a function that I can update all rows and set the values in MONTH column based on the value in WEEK_NO?

For example, WEEK_NO 1 is MONTH 1. WEEK_NO 5 (February) is MONTH 2, and so on.

TIA.

Update. Google found the following:
declare @Year char(4), @Week tinyint
select @Year = '2003', @Week = 10
select month(dateadd(wk,@Week,@Year + '/01/01'))
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Reply
Map
View

Click here to load this message in the networking platform