Public Function funIsWorkDay(datDay As Date) As Boolean
Dim strFiltr As String
Dim Except As Integer
strFiltr = "DayExc=" & Day(datDay) & " AND MonthExc=" & Month(datDay) & " AND YearStart<=" & Year(datDay) & " AND (YearEnd>=" & Year(datDay) & " Or YearEnd=0)"
Except = Nz(DLookup("WorkDay", "tblException", strFiltr), 2)
Select Case Except
Case Is = 2
funIsWorkDay = DatePart("w", datDay, vbUseSystemDayOfWeek) < 6
Case Else
funIsWorkDay = Except
End Select
End Function
Public Function funNextWorkDay(ByVal datDay As Date, Optional blnForvard As Boolean = True, Optional lngShift As Long = 0) As Date
Dim lngStep As Long
If blnForvard Then lngStep = 1 Else lngStep = -1
datDay = datDay + lngStep + lngShift
Do Until funIsWorkDay(datDay)
datDay = datDay + lngStep
Loop
funNextWorkDay = datDay
End Function
|