Counts the number of business days
Add or subtract a number of business days from a date
No holidays calculated yet.
Function BusinessDateAdd(ByVal days As Long, ByVal StartDate As Date, Optional ByVal SaturdayIsHoliday As Boolean = True) As Date
Do While days
StartDate = StartDate + Sgn(days) ' increment or decrement the date
If Weekday(StartDate) < > vbSunday And (Weekday(StartDate) < > vbSaturday Or Not SaturdayIsHoliday) Then ' check that it is a week day
days = days - Sgn(days) ' days becomes closer to zero
End If
Loop
BusinessDateAdd = StartDate
End Function
Do While days
StartDate = StartDate + Sgn(days) ' increment or decrement the date
If Weekday(StartDate) < > vbSunday And (Weekday(StartDate) < > vbSaturday Or Not SaturdayIsHoliday) Then ' check that it is a week day
days = days - Sgn(days) ' days becomes closer to zero
End If
Loop
BusinessDateAdd = StartDate
End Function
ByVal days As Long, ByVal StartDate As Date, Optional ByVal SaturdayIsHoliday As Boolean = True
Views 104
Downloads 55
CodeID
DB ID