11 Ağustos 2007 Cumartesi

Add or Subtract a number of Business days from a Date

' Note that it doesn't take Christmas, Easter and
' other holidays into account

Function 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 = StartDate
End Function


0 Comments: