Public Function WeekInMonth(dte As Date) As Integer
Dim strMonthYear As String
Dim dteFirstMonth As Date
Dim intDaysDiff As Integer
Dim intDayFirstOfMonth As Integer
strMonthYear = Month(dte) & "/" & Year(dte)
dteFirstMonth = "01" & "/" & strMonthYear
intDayFirstOfMonth = WeekDay(dteFirstMonth, vbMonday)
intDaysDiff = (dte - dteFirstMonth) + intDayFirstOfMonth - 1
WeekInMonth = Int(intDaysDiff / 7) + 1
End Function
Aşağıdaki fonksiyon ile ayın kaçıncı haftası olduğunu bulabilirsiniz.