Function Dates Times Class

NumberWorkDays

Determine the number of business days between two dates, taking into account holidays that fall between the two dates.

Signature (Visual Basic / VBA)

Public Function NumberWorkDays( _
      ByVal vFmDate As Variant _
    , ByVal vToDate As Variant _
    , ParamArray vHolidays() As Variant _
    ) As Variant

Code Example

    NumberWorkDays(#1/1/99#, #3/15/99#) = 52
    NumberWorkDays(#1/1/99#, #3/15/99#, Array(#10/30/98#, #3/1/99#)) = 51
    NumberWorkDays(#3/15/99#, #1/1/99#, Array(#10/30/98#, #3/1/99#)) = -51

Parameters

Parameter Description
vFmDate The beginning (first day) of the date interval. Function returns Null if vFmDate is Null or cannot be interpreted as a Date. The time component of vFromDate (if any) is ignored.
vToDate The end (last day) of the date interval. Function returns Null if vToDate is Null or cannot be interpreted as a Date. The time component of vToDate (if any) is ignored.
vHolidays Optional holidays that are NOT to be considered work days. Can be numbers, one-dimensional numeric arrays, one-dimensional Variant arrays, one-dimensional Variant arrays with embedded arrays, or any combination of these. Any duplicate holidays within vHolidays will be ignored.

Notes & Version History

Summary This function considers work days to be the weekdays (Monday through Friday), minus any holidays that occur on a weekday.
Note This function returns the exact same results as the Microsoft Excel NETWORKDAYS function.
v2.0 Addition This function is new to this version of Entisoft Tools. Make sure datFm is before datTo.