calculate the month from the year and week number in excel

Pricey picture Pricey · Jun 1, 2012 · Viewed 32.7k times · Source

In Excel 2007 I have a Year number and Week number and I want to work out the Month number.

The catch is that in my case the start of every week is a monday, so some weeks will overlap through the years.

Examples:

Year: 2012
Week 1 started: Monday 2nd January
Sunday 1st January was in week 52 of 2011

So given the below:

Year: 2011
Week: 10

How can I work out that week 10 started on 7th March and therefore week 10 was in Month number 3.

Thanks for any help on this.

Answer

barry houdini picture barry houdini · Jun 1, 2012

You can actually do this a little more simply. If Year is in A2, e.g. 2012, and week number is in B2 you can get the start date of that week with this formula

=DATE(A2,1,-2)-WEEKDAY(DATE(A2,1,3))+B2*7

format as date

......clearly you can wrap that in a MONTH function to get the month, i.e.

=MONTH(DATE(A2,1,-2)-WEEKDAY(DATE(A2,1,3))+B2*7)

format result cell as general

Explanation

The above finds the date of the last Monday of the previous year and then adds the number of weeks * 7 to give the start date of the relevant week.

The first day of the year for ISO weeks is always the only Monday in the period 29th Dec to 4th Jan, so to find that date we can find the Monday immediately before 5th Jan.

To find the Monday immediately before any date you can use this generic formula

=date-WEEKDAY(date-2)

so if date is 5th Jan of the year shown in A2 that's the same as

=DATE(A2,1,5)-WEEKDAY(DATE(A2,1,3))

.....but that gives the first Monday of this year, so if I want the last Monday of the previous year I can subtract 7 - one way to do that is to subtract 7 from the 5 to get -2 hence:

=DATE(A2,1,-2)-WEEKDAY(DATE(A2,1,3))