Your original post does not mention that you are looking for an ISO week that may have done what you want obscurely.
NET GetWeekOfYear using FirstFourDayWeek and DayOfWeek.Monday almost like an ISO week. The difference is that the ISO week is always seven days. Keep in mind that an ISO date is not only a different format, but also a different calendar with its own terms (for example, high week). On the other hand, your default calandar is Gregorian.
It's easy to configure NET WOY for an ISO week:
Public Shared Function GetISOWeekOfYear(dt As DateTime) As Integer Dim cal As Calendar = CultureInfo.InvariantCulture.Calendar Dim d As DayOfWeek = cal.GetDayOfWeek(dt) If (d >= DayOfWeek.Monday) AndAlso (d <= DayOfWeek.Wednesday) Then dt = dt.AddDays(3) End If Return cal.GetWeekOfYear(dt, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday) End Function
Simple tester for 12/31 / xxxx:
For n As Integer = 1990 To 2016 Console.WriteLine("{0}: week:{1}", n.ToString, GetISOWeekOfYear(New DateTime(n, 12, 31)).ToString) Next
A conclusion of only the latter:
2005: week: 52
2006: week: 52
2007: Week: 1 | 2008: week: 1
2009: week: 53
2010: Week: 52
2011: week: 52
2012: Week: 1 | 2013: Week: 1 | 2014: Week: 1
2015: Week: 53
2016: week: 52
source share