devxlogo

BusinessDateAdd – Add or subtract a number of business days from a date

BusinessDateAdd – Add or subtract a number of business days from a date

' add or subtract a number of business days from a date'' Note that it doesn't take Christmas, Easter and' other holidays into accountFunction BusinessDateAdd(ByVal days As Long, ByVal StartDate As Date, _    Optional ByVal SaturdayIsHoliday As Boolean = True) As Date    Do While days        ' increment or decrement the date        StartDate = StartDate + Sgn(days)        ' check that it is a week day        If Weekday(StartDate)  vbSunday And (Weekday(StartDate)  vbSaturday _            Or Not SaturdayIsHoliday) Then            ' days becomes closer to zero            days = days - Sgn(days)        End If    Loop    BusinessDateAdd = StartDateEnd Function

devx-admin

Share the Post: