This article will help you:
- understand what a Calculate dates action node does and how to use it
- find example use cases for the Calculate dates action
- understand how skipping or including/excluding dates or days will work
What is the Calculate dates action?
The Calculate Dates action allows authors to add or subtract days, weeks, months, and/or years to a date value.
Node type | Node builder |
Why would you use Calculate dates?
Use the Date calculation action to add or subtract days, weeks, months or years from a given date. For instance, you can use the Date calculation action to determine how long ago you last had contact with the user or if a submission deadline has already passed. You can also define precise dates or days to be skipped which can be used e.g. to determine deadlines with respect to bank holidays. If you wish to determine the days between dates, please refer to Days between Dates.
Example use cases
Calculate periods
Use the Date calculation action to determine how long ago you last had contact with the user. Dates can be calculated from the day on which the user completes your module. This is particularly useful as a risk assessment and due diligence exercise. For instance, if the last business contact was more than a year ago from the date the user interacts with your module, this can result in a higher risk score.
Submission deadlines
You can also calculate deadlines, such as submission deadlines for documents. Then your module can check if the user-submitted date has already passed or you can reference the date in the Result.
How to use the Calculate dates action
Follow the steps below to add a Date calculation action to your module.This section covers the basic procedure to add a date calculation to your module. See below for more advanced instructions.
- Click the plus icon “ + ” on a node.
- Select New Action.
- In the Action node dropdown that opens, choose Date calculation.
- Select Date calculation and give your calculation a name. This name will not be displayed to your user.
You should now see several empty parameters on the attribute editor. Learn about filling out this form in the Parameters section below.
Perform a risk-assessment based on last contact
Let's say you want to automatically prohibit transactions if the user's last date of contact was more than a year ago. Performing this type of date calculation consists of three main steps.
First, you need to add a Date node to your tree which requires the user to input their last date of contact, as shown below.
Then, directly under this Date node, add a Date calculation action to your module following the procedure above. Reference the Date node you created in the START DATE field. Choose between the " Add " and "Subtract" buttons to perform a calculation and enter the correct number of years, months, weeks, or days. Learn more about how to populate this form in the Parameters section below.
Lastly, create a new transition from the Date calculation action to add conditional logic, as shown below. Note that you can reference the Date of interaction in the conditions.
Parameters
Start date |
Enter a start date for your calculation directly into this field or reference a date collected in another node. |
First day inclusivity |
Select whether the first day is included for the date calculation. Including the first day means that the defined start date counts as included within the time period shift. |
"Add" and "Subtract" operations |
Choose between addition (Add) or subtraction (Subtract) operation to perform on your start date. |
Days/Weeks/Months/Years |
By choosing one days, months, weeks and years you can define time unit that is added or subtracted from your start date. Complete your calculation by entering the number of days, weeks, months or years you wish to increase or decrease your start date by. Note that only whole numbers are accepted in each field, thus decimal numbers are rounded down. |
Output date format |
From the drop-down menu, select the way you wish the day, month and year to be formatted in the output. |
Define Weekdays to Skip |
Choose weekdays to be skipped during the date calculation. In case the toggle is switched off the skip weekdays functionality is disabled, although weekdays might be selected. Note that it is not possible to select all weekdays. |
Define Dates to Skip |
Choose custom dates, date variables or interaction based dates to be skipped during the date calculation. In case the toggle is switched off the skip dates functionality is disabled, although dates might be selected. |
Skip last day only |
Select if skipping days/dates should only apply to the end date that was calculated, which means that inbetween skipped day/dates are ignored. Note that if the selected time unit is one of "weeks", "months" or "years" (i.e. other than "days) the toggle is always set active. |
Advanced information on date calculation principles
Skip functionality and selected time unit
The working principle of skipping weekdays/dates slightly varies based on the selected time unit:
- If the selected time unit is "days" the calculated end date is shifted by one day for each skipped weekday/date between the start date and potential end date.
- If the selected time unit is one of "weeks", "months" or "years" the calculated end date is only shifted when it coincides with a skipped weekday/date. In other words if the selected time unit is other than "days", skip last day only is always set active.
Illustrated Examples
The following illustrated examples provide more insights into the mechanics behind date calculation.
Symbols used in illustrations:
Examples: Default Settings
In the above example 01.06.20 is selected as start date and 5 days are added. This results in 01.11.20.
In the above example 01.13.20 is selected as start date and 5 days are subtracted. This results in 01.08.20.
Examples: Skip Dates
In the above example 01.06.20 is selected as start date, the defined skip dates are 01.08.20 and 01.14.20 and 5 days are added. This results in 01.12.20. Note that the skip date 01.14.20 is not considered since the time range expansion is not large enough.
In the above example 01.13.20 is selected as start date, the defined skip dates are 01.10.20 and 01.06.20 and 5 days are subtracted. This results in 01.07.20. Note that the skip date 01.06.20 is not considered since the time range expansion is not large enough.
In the above example 01.06.20 is defined as start date, 01.13.20 is defined as skip date and 2 weeks are added. Note that in case the selected time range is other than "days", "skip last day only" is always set active. Thus the defined skip date is ignored and the calculated end date is 01.20.20.
Examples: Start date inclusivity
In the above example 01.06.20 is selected as inclusive start date, 01.12.20 is selected as skip date and 5 days are added. The intuition behind an inclusive start date is that the jump to the date next to the start date counts as two days. Thus the calculated end date is 01.10.20.
In the above example 01.06.20 is selected as inclusive start date, 01.10.20 is selected as skip date and 5 days are added. Since the skip date is now included within the given time range it is considered, thus the calculated end date is 01.11.20.
In the above example 01.13.20 is selected as inclusive start date, 01.11.20 and 01.12.20 are selected as skip dates and 5 days are subtracted. The calculated end date is 01.07.20.
Examples: Skip last day only
In the above example 01.06.20 is selected as start date, 01.08.20 is selected as skip date, "skip last day only" is set active and 5 days are added. Due to "skip last day only" is set active, the defined skip date is ignored, thus the calculated end date is 01.11.20.
In the above example 01.06.20 is selected as start date, 01.08.20 and 01.11.20 are selected as skip dates, "skip last day only" is set active and 5 days are added. Due to "skip last day only" is set active, skip date 01.08.20 is ignored. Since 01.11.20 is skipped it can not be the calculated end date, thus it is jumped over and the actual calculated end date is 01.12.20.