Get Month from Week number

Hello there,

I have an Excel sheet with a row of week numbers. It’s just each cell with a different number like: D1 contains “34”, E1 “35”, F1 “36” and so on.
Now I want to get the correct month for each week number and write it in the cell below

The result should look like this:

I need this because I have to add up all columns from each month. E.g. a column called “Sum of August” So is this step necessary or this there an easier way to do this?

Hello @Loons,

It’s a tricky one let’s break it down.

  1. Get the Month Number : Date.ParseExact("01/01/"+Now.ToString("yyyy"),"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).AddDays(WeekOfYear*7).Month. WeekOfYear is a Integer variable.
  2. Get the Name of the Month from the Month Number obtained in Step 1. System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(MonthNumber). MonthNumber is a Integer Variable.

Hope that helps ! Kudos :slight_smile:

Regards,
Nithin

4 Likes

Thank you for your help
But if I set the Date to 01/01 like you wrote, I just get “January”… So I just get the month for the Date I set right?
But until now the week numbers from each cell aren’t involved :confused: How do I do this?

Hello @Loons,

In the example I have explained you have to set the WeekOfYear (In Step 1) to get the MonthNumber & then in Step 2 get Name of the Month using the MonthNumber obtained from Step 1.

Hope that helps ! Kudos :slight_smile:

Regards,
Nithin

1 Like

Okay, I got it…Sorry I misunderstood it
Thank you for your help!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.