# Weeknumber for 30.12.2019 is wrong when using DatePart("ww", "30.12.2019", vbMonday, vbFirstFourDays)

• ### Question

• The weeknumber for 30.12.2019 is calculated to 53 when using DatePart("ww", "30.12.2019", vbMonday, vbFirstFourDays), but it should be 1.

Running the sequence below, it can be seen that it is only the 30.12.2019 that gets wrong.

Have testet for the change between 2030 and 2031 (which also has two dates in December in the first week), but here it is right for all the dates!

Dim d_Date As Date
Dim weeknumber As Integer
Dim i As Integer

Debug.Print "***********"
d_Date = Format("28.12.2019", "dd.mm.yyyy")

For i = 0 To 10
weeknumber = DatePart("ww", d_Date, vbMonday, vbFirstFourDays)
Debug.Print d_Date; "-"; weeknumber; Weekday(d_Date, vbMonday)
d_Date = d_Date + 1
Next i

The result is:

28.12.2019 - 52  6
29.12.2019 - 52  7
30.12.2019 - 53  1
31.12.2019 - 1  2
01.01.2020 - 1  3
02.01.2020 - 1  4
03.01.2020 - 1  5
04.01.2020 - 1  6
05.01.2020 - 1  7
06.01.2020 - 2  1
07.01.2020 - 2  2

• Edited by Monday, August 19, 2019 7:32 PM
Monday, August 19, 2019 6:26 PM

• Hi

Following method also returns 53 - maybe it is right. Personally, I can't imagine a week containing a date can be in the next year - doesn't make sense to me.

```    Dim dfi As Globalization.DateTimeFormatInfo = Globalization.DateTimeFormatInfo.CurrentInfo
Dim calendar As Globalization.Calendar = dfi.Calendar
Dim weekOfyear As Integer = calendar.GetWeekOfYear(
CDate("30.12.2109"),
dfi.CalendarWeekRule,
DayOfWeek.Monday)```

Regards Les, Livingston, Scotland

Monday, August 19, 2019 7:10 PM
• Check this post out, ignore the C#.

https://code-examples.net/en/q/aa34f1

Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

NuGet BaseConnectionLibrary for database connections.

StackOverFlow

Monday, August 19, 2019 7:15 PM

### All replies

• Hi

Following method also returns 53 - maybe it is right. Personally, I can't imagine a week containing a date can be in the next year - doesn't make sense to me.

```    Dim dfi As Globalization.DateTimeFormatInfo = Globalization.DateTimeFormatInfo.CurrentInfo
Dim calendar As Globalization.Calendar = dfi.Calendar
Dim weekOfyear As Integer = calendar.GetWeekOfYear(
CDate("30.12.2109"),
dfi.CalendarWeekRule,
DayOfWeek.Monday)```

Regards Les, Livingston, Scotland

Monday, August 19, 2019 7:10 PM
• Check this post out, ignore the C#.

https://code-examples.net/en/q/aa34f1

Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

NuGet BaseConnectionLibrary for database connections.

StackOverFlow

Monday, August 19, 2019 7:15 PM