addWorkingDays function in the Factory

The addWorkingDays function adds a given number of working days (excluding weekends) to a date attribute.


Parameters

addWorkingDays(date, nday)

Parameter

Description

date

The date attribute we want to add working days to. The date parameter is mandatory.

nday

The number of working days to add to the chosen date attribute. The nday parameter is mandatory.

Date type valid formats (if the values aren’t this format, the function will return an error).

  • 2019/10/12;

  • 12/10/2019;

  • 2019-10-12;

  • 12-10-2019;

  • 2019/Oct/12;

  • 12/Oct/2019;

  • 2019-Oct-12;

  • 12-Oct-2019.


Example

The following example uses the Bike sales dataset.

Description

Screenshot

In this example, we want to add five working days to the Date attribute.

We type the following formula in the addwd attribute:

addWorkingDays($"Date",5)

and the attribute will be filled with the Date attribute’s values postponed by five working days, which might be more than five days, as weekends are excluded by the function and it considers only working days, not calendar days.

The results are as follows:

  • In row 1, the Date value 2013-11-26 becomes 2013-12-03: the 26th of November was Tuesday, and the 3rd of December was Monday. Five working days have been added

and so on.