Link to home
Start Free TrialLog in
Avatar of zen770
zen770

asked on

How to find how many sundays are in a month?

Hi
Is there a simple algorithm that will tell me how many days are in a month - like how many sundays or how many mondays, etc?

Avatar of jbil
jbil

One method..

Private Function getNumWeekdays(dayName As String, monthName As Integer, YrName As Integer)
Dim num, i As Integer

For i = 1 To 31
 On Error GoTo enufDays
 myday = Weekday(monthName & "/" & i & "/" & YrName)
 MyWeekDay = WeekdayName(myday)
  If MyWeekDay = dayName Then num = num + 1
Next

enufDays:
getNumWeekdays = num
Debug.Print getNumWeekdays
End Function

Private Sub Form_Load()
getNumWeekdays "Sunday", 6, 2002
End Sub

ASKER CERTIFIED SOLUTION
Avatar of BGillham
BGillham

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial