Get the number of the week of the month from a given date

user2453446 picture user2453446 · Feb 11, 2014 · Viewed 13.6k times · Source

I have a set of dates from which I must obtain the week of the month.

There is a lot of literature on how to obtain the week of the year using VBA code but not the week number of the month.

For instance 03-Mar-13 would give week 1 of March, instead I end up with a result of week 10.

Answer

user3496574 picture user3496574 · Jul 22, 2014

I know this is old, but I came across this and thought I would add my code. (Built from rvalerio's answer)

Private Function getWeekOfMonth(testDate As Date) As Integer
    getWeekOfMonth = CInt(Format(testDate, "ww")) - CInt(Format(Format(testDate, "mm/01/yyyy"), "ww")) + 1
End Function