Choose where you’d like to start

workDaysBetween

Overview

The workDaysBetween function returns the number of workdays between two given dates.

Note:

  • This function allows for defining weekends, holiday lists.
  • If end date is greater than the start date, then the number of days will be represented as a negative value.
  • The number of days returned is exclusive of the start date.

Return Type

Syntax

<variable> = <start_date>.workDaysBetween(<end_date>,<weekends_list>,<holiday_list>);

where,

ParameterData typeDescription
<variable>NUMBERVariable which will contain the number of workdays between two dates.
<start_date>DATE-TIME/TEXT

The date-time value after which the number of workdays should be calculated.

<end_date>DATE-TIME/TEXT

The date-time value until which the number of workdays should be calculated.

Note: If end_date is lesser than the start_date, then a negative value will be returned.

<weekends_list>

(optional)

COLLECTION

The list of date values (weekends) that should be considered while listing work days.

Note: By default, the weekends list is {Saturday, Sunday}

<holidays_list>

(optional)

COLLECTION

The list of holidays that should be considered while listing work days.

Note: If no holidays are provided, any day (except weekends) will be considered a working day.

Examples

The below example lists all the work days between Jan 1, 2020 to Jan 6, 2020. 

 start_date= '1-Jan-2020';
 end_date = '6-Jan-2020';
 num_work_days =  start_date.workDaysBetween(end_date, {"Saturday","Sunday"},{'02-Jan-2020','03-Jan-2020'});
 //num_work_days is assigned the value 1

Related Links

Get Started Now

Execute