ManiMuthuPandi ManiMuthuPandi - 5 months ago 21
SQL Question

How to get month value using week value sql server

I want to get month value using week no.
I have week numbers stored in a table with year value.

enter image description here

How to query database to get month value using that week value.

I am using SQL

Answer

You can try this:

  SELECT DATEPART(m,DATEADD(wk, DATEDIFF(wk, 6, '1/1/' + CAST(t.year as VARCHAR(4))) + (t.week-1), 6))