Skip to main content

Date.work_days_until

work_days_untilendholidaysinclude_end_date

Group: DateTime

Documentation

Counts workdays between self (inclusive) and the provided end date (exclusive). Produces a warning for a Date that is before epoch start. See Date_Time.enso_epoch_start.

Arguments

  • end: the end date of the interval to count workdays in.
  • holidays: dates of holidays to skip when counting workdays.
  • include_end_date: whether to include the end date in the count. By default the end date is not included in the interval.

Examples

Count the number of workdays between two dates.

      from Standard.Base import Date

example_workdays = Date.new 2020 1 1 . work_days_until (Date.new 2020 1 5)

Remarks

Including the end date

To be consistent with how we usually represent intervals (in an end-exclusive manner), by default the end date is not included in the count. This has the nice property that for example to count the work days within the next week you can do date.work_days_until (date + (Period.new days=7)) and it will look at the 7 days starting from the current date and not 8 days. This also gives us a property that date.work_days_until (date.add_work_days N) == N for any non-negative N. On the other hand, sometimes we may want the end date to be included in the count, so we provide the include_end_date argument for that purpose. Setting it to True should make the result consistent with the NETWORKDAYS function in Excel and similar products.