Number of Business days between two dates.
Note that it doesn't take Christmas, Easter and other holidays into account
Function BusinessDateDiff(StartDate, EndDate, SaturdayIsHoliday)
Dim incr
StartDate = CInt(StartDate) ' ensure we don't take time part into account
EndDate = CInt(EndDate)
If StartDate < EndDate Then incr = 1 Else incr = -1 ' incr can be +1 or -1
Do Until StartDate = EndDate
StartDate = StartDate + incr ' skip to previous or next day
If Weekday(StartDate) < > vbSunday And (Weekday(StartDate) < > vbSaturday Or Not SaturdayIsHoliday) Then
BusinessDateDiff = BusinessDateDiff + incr ' if it's a weekday add/subtract one to the result
End If
Loop
End Function
Dim incr
StartDate = CInt(StartDate) ' ensure we don't take time part into account
EndDate = CInt(EndDate)
If StartDate < EndDate Then incr = 1 Else incr = -1 ' incr can be +1 or -1
Do Until StartDate = EndDate
StartDate = StartDate + incr ' skip to previous or next day
If Weekday(StartDate) < > vbSunday And (Weekday(StartDate) < > vbSaturday Or Not SaturdayIsHoliday) Then
BusinessDateDiff = BusinessDateDiff + incr ' if it's a weekday add/subtract one to the result
End If
Loop
End Function
StartDate, EndDate, SaturdayIsHoliday
Views 144
Downloads 44
CodeID
DB ID