Sub Test()
Dim X
X = MnthNum("7/15/2013")
End Sub
Function MnthNum(Dte As Date) As Long
Dim D As Long
Dim M As Long
Dim Y As Long
Dim Diff As Long
D = Day(Dte) 'Returns day number of month of Dte
M = Month(Dte) 'Returns month number of Dte
Y = Year(Dte) 'I dunno ;)
'Num Days in this month of Dte is same as
'Difference in days between 1st day next month of Dte, and 1st of this month of Dte
Diff = DateSerial(Y, M + 1, 1) - DateSerial(Y, M, 1)
If D > Diff / 2 Then
MnthNum = M
Else
MnthNum = M - 1
If MnthNum = 0 Then MnthNum = 12
End If
End Function