Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate month number based on week no
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Calculate month number based on week no
Divers
Thread ID:
01653240
Message ID:
01653240
Vues:
59
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
Répondre
Fil
Voir

Click here to load this message in the networking platform