- Home
·
- Miscellaneous
·
- Function that returns the number of working days between two dates
Function that returns the number of working days between two dates
Function that returns the number of working days between two dates
Rate Function that returns the number of working days between two dates
(1(1 Vote))
Private Function WorkDays(ByVal dtBegin As Date, ByVal dtEnd As Date) As Long
Dim dtFirstSunday As Date
Dim dtLastSaturday As Date
Dim lngWorkDays As Long
dtFirstSunday = dtBegin + ((8 - Weekday(dtBegin)) Mod 7)
dtLastSaturday = dtEnd - (Weekday(dtEnd) Mod 7)
lngWorkDays = (((dtLastSaturday - dtFirstSunday) + 1) / 7) * 5
If dtFirstSunday <> dtBegin Then
lngWorkDays = lngWorkDays + (7 - Weekday(dtBegin))
End If
If dtLastSaturday <> dtEnd Then
lngWorkDays = lngWorkDays + (Weekday(dtEnd) - 1)
End If
WorkDays = lngWorkDays
End Function
Function that returns the number of working days between two dates Comments
No comments yet — be the first to post one!
Post a Comment