You are here


Get the first day of a given week (ISO 8601)

Most programming languages provide a way to get the week number of a given date. For an SQL example, check out my previous article: SQL: year of an ISO week.

In C# you can use the following:

int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

But there's usually no function provided to get the first day of a given week and year. The shortest (but still readable) way that I can get up with in C# is the following:

Subscribe to RSS - c#