How can I determine the week number of a certain date?

You must use Calendar.GetDayOfWeek and Calendar.GetWeekOfYear in preference to writing yourself. You can guarantee that if you write any date / time handling code yourself it will contain faults and won’t work in different locales. public class Row { public string MonthWeek { get; set; } public string Year { get; set; } public string … Read more

Week number of the month?

In order to use straight division, the day of month for the date you’re looking at needs to be adjusted according to the position (within the week) of the first day of the month. So, if your month happens to start on a Monday (the first day of the week), you can just do division … Read more

How to get week numbers from dates?

Base package Using the function strftime passing the argument %V to obtain the week of the year as decimal number (01–53) as defined in ISO 8601. (More details in the documentarion: ?strftime) strftime(c(“2014-03-16”, “2014-03-17″,”2014-03-18”, “2014-01-01”), format = “%V”) Output: [1] “11” “12” “12” “01”

Calculate date from week number

I had issues with the solution by @HenkHolterman even with the fix by @RobinAndersson. Reading up on the ISO 8601 standard resolves the issue nicely. Use the first Thursday as the target and not Monday. The code below will work for Week 53 of 2009 as well. public static DateTime FirstDateOfWeekISO8601(int year, int weekOfYear) { … Read more