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
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?
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.
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.
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 How do I do this?
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.