eckert1961
Registered User.
- Local time
- Today, 14:28
- Joined
- Oct 25, 2004
- Messages
- 90
Hello,
I'm using the following code to calculate the number of Monday's and Wednesday's in a selected month.
This works great but I would like to modify it so that along with what it already does I have the option of calculating the number of Monday's and Wednesday's between 2 dates.
Any assistance would be greatly appreciated.
Thanks and regards,
Chris
I'm using the following code to calculate the number of Monday's and Wednesday's in a selected month.
Code:
Public Function GetWeekDays(pmoyr As String, pdays As String) As Integer
'************************************************
'Purpose: Compute number of weekdays
' in the specified mm/yyyy
' where 1 = Sunday thru 7 = Saturday
'Coded by: raskew
'Inputs: 1) ? GetWeekdays("02/2008", "2") 'count Mondays
' 2) ? GetWkdays("07/2008", "246") 'count Mondays, Wednesdays, Fridays
'Output: 1) 5
' 2) 13
'************************************************
Dim dteStart As Date
Dim dteEnd As Date
Dim intEnd As Integer
Dim intStart As Integer
Dim i As Integer
dteStart = DateValue(pmoyr)
dteEnd = DateAdd("m", 1, dteStart) - 1
For i = 1 To Len(pdays)
intStart = intStart + IIf(Weekday(dteStart) <= Int(Mid(pdays, i, 1)), 1, 0)
Next i
For i = 1 To Len(pdays)
intEnd = intEnd + IIf(Int(Mid(pdays, i, 1)) <= Weekday(dteEnd), 1, 0)
Next i
GetWeekDays = intStart + Len(pdays) * (DateDiff("ww", dteStart, dteEnd) - 1) + intEnd
End Function
Any assistance would be greatly appreciated.
Thanks and regards,
Chris