Team,
In need of some help. I have a script that I am using to calculate holidays, however having some issues with it. It is not using the first day after the holiday as day zero. For example, if a shipment is picked up on 5/29 and has a '5' day turnaround, it should be due on 6/8 (excluding holidays). Any help is appreciated.
Public Function PlusWorkdays(dteStart As Date, intNumDays As Long) As Date
'-- Advance dteStart to Monday if needed.
If Weekday(dteStart, vbMonday) > 5 Then
PlusWorkdays = dteStart + (7 - Weekday(dteStart, vbMonday)) + 1
Else
PlusWorkdays = dteStart
End If
Do While intNumDays > 0
PlusWorkdays = DateAdd("d", 1, PlusWorkdays)
' If Weekday(PlusWorkdays, vbMonday) <= 5 Then
'-- If you have a Holiday Table use the next IF instead!
If Weekday(PlusWorkdays, vbMonday) <= 5 And _
IsNull(DLookup("[HoliDate]", "tblHolidays", _
"[HoliDate] = " & Format(PlusWorkdays, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
'-- The above Format of PlusWorkdays works with US or UK dates!
intNumDays = intNumDays - 1
End If
Loop
End Function
In need of some help. I have a script that I am using to calculate holidays, however having some issues with it. It is not using the first day after the holiday as day zero. For example, if a shipment is picked up on 5/29 and has a '5' day turnaround, it should be due on 6/8 (excluding holidays). Any help is appreciated.
Public Function PlusWorkdays(dteStart As Date, intNumDays As Long) As Date
'-- Advance dteStart to Monday if needed.
If Weekday(dteStart, vbMonday) > 5 Then
PlusWorkdays = dteStart + (7 - Weekday(dteStart, vbMonday)) + 1
Else
PlusWorkdays = dteStart
End If
Do While intNumDays > 0
PlusWorkdays = DateAdd("d", 1, PlusWorkdays)
' If Weekday(PlusWorkdays, vbMonday) <= 5 Then
'-- If you have a Holiday Table use the next IF instead!
If Weekday(PlusWorkdays, vbMonday) <= 5 And _
IsNull(DLookup("[HoliDate]", "tblHolidays", _
"[HoliDate] = " & Format(PlusWorkdays, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
'-- The above Format of PlusWorkdays works with US or UK dates!
intNumDays = intNumDays - 1
End If
Loop
End Function