In VBA I want to convert a date as 03/11/2017(DD/MM/YYYY) into the week number for that date.
Until now I have the following code:
\'geting the d
Be carefull when it comes to week numbers as there are different definitions around. The Excel definition differs from the ISO definition. To get the ISO weeknumber use (copied From http://www.rondebruin.nl/win/s8/win001.htm)
Public Function IsoWeekNumber(d As Date) As Integer
Dim d2 As Long
d2 = DateSerial(Year(d - Weekday(d - 1) + 4), 1, 3)
IsoWeekNumber = Int((d - d2 + Weekday(d2) + 5) / 7)
End Function