Skip to main content
Roberty Studio
RPADate and time

Calculate date difference

Calculate date difference

Calculates the difference between two dates and returns the result in the desired time unit. Ideal for measuring deadlines, calculating ages, counting overdue days or checking how long ago an event happened — without having to perform manual calculations.


Options​

Initial date​

Use a date relative to the robot's execution?​

Defines whether the initial date will be the current date at the moment of the execution. Select Yes to use it automatically, or No to provide a specific date.

Input format date​

Select the format of the initial date provided: Traditional (31/12/2024), In full (31 de dezembro de 2024) or International (2024-12-31). This field is only shown when Use a date relative to the robot's execution? is set to No.

Date to be formatted​

Enter the start date of the interval. This field is only shown when Use a date relative to the robot's execution? is set to No.

Final date​

Use a date relative to the robot's execution?​

Defines whether the final date will be the current date at the moment of the execution. Select Yes to use it automatically, or No to provide a specific date.

Input format date​

Select the format of the final date provided. This field is only shown when Use a date relative to the robot's execution? is set to No.

Date to be formatted​

Enter the end date of the interval. This field is only shown when Use a date relative to the robot's execution? is set to No.

Time unit​

Select the unit in which the difference between the dates will be calculated: Day, Week, Month or Year.

Returns​

Javascript code​

js
actions["action-id"].value // difference between the dates in the unit selected (Number)

Field selection​

  • value — numeric value of the distance between the two dates (Number)

Rules and Conditions​

  • The result is calculated as the final date minus the initial date, in whole units. If the initial date is later than the final date, the value returned will be negative.
  • For each date, when Use a date relative to the robot's execution? is No, the date provided must match the format selected in Input format date.