addDuration (time)
  • 02 May 2024
  • Dark
    Light
  • PDF

addDuration (time)

  • Dark
    Light
  • PDF

Article summary

Task Purpose

Unlike the getTime task (which provides a system timestamp), the addDuration task allows you to add a duration of time and then return the adjusted timestamp for continued use in the automation.

Potential Use Case

If there is a date value provided in a record, you could use the addDuration task to determine what the timestamp would be if additional time were added. Let's say you are adding 6 months to a poll record. Using this task, the automation run would generate a result similar to the following: "Last poll occurred on 01JAN, next poll will occur on 01JUN".

Task Properties

Input and output properties are shown below.

Input Variables

Incoming Type Description Example
inputTime Object Required. A timestamp provided from the result of a previous automation task. This object must contain the following key-value pairs:
time- A string representation of the time.
formatString- The moment.js format the value of time must adhere to.
{ "time": "2023-04-28T01:21:14.052000-1100", "formatString": "YYYY-MM-DDTHH:mm:ss.SSSSSSZZ" }
offsetDuration Object Required. A duration to offset the current time expressed as an object literal notation. For example: {"days": 7,"months":1} will add 7 days and 1 month to the current system timestamp. Numeric values entered without any other designators will be treated as milliseconds (default). {"days": 7,"months":1}
{"hours": 4}
31556926000

Note: If using object literal notations in the offsetDuration property, you must include the curly braces in the value. See examples below. For more information regarding the object literal notation, see the moment.js documentation.


Output Variables

Outgoing Type Description
newTime Object The new time that is returned after adding the given duration to the inputTime object.

Note: The newTime object will inherit the same format as the provided inputTime. Currently the addDuration task does not provide a mechanism to alter the time format.


How to Configure the Task

Example 1

In this example from IAP:

  • The inputTime property is provided by the Get time task, which is located elsewhere in the workflow. The reference variable is time.
  • Using the object literal notation, the offsetDuration will add four (4) days to the time input value.
  • The outgoing newTime variable will be the result of adding 4 days to the inputTime value that was provided at the time the incoming properties were set.
  • Using this example, let's say the inputTime variable was "2020-06-01". Adding 4 days would mean the resulting newTime would be "2020-06-05".

addDuration-23.1-ex01

Example 2

In this second example:

  • The inputTime property is provided by the Get time task, which is located elsewhere in the workflow. The reference variable is time.
  • Notice that the time variable provided by the Get time reference task should have an offsetDuration of 8640000 milliseconds (24 hours) added to it. By default, this field accepts values as milliseconds and does not require the object literal notation.
  • The outgoing newTime variable will be the result of adding 24 hours to the inputTime value that was provided.

addDuration-23.1-ex02

Example 3

In this last IAP example:

  • The inputTime property is provided by the Get time task, which is located elsewhere in the workflow. The reference variable is time.
  • The time variable provided by the Get time reference task should have an offsetDuration of 4 hours and 6 months added to it. Notice the use of the object literal notation.
  • The outgoing newTime variable will be the result of adding 6 months and 4 hours to the inputTime value that was provided.

addDuration-23.1-ex03

How to Use a Manual Reference Variable Entry (inputTime)

To enter the inputTime object manually, use the format below for Year-Month-Date-Time ("yyyy-MM-dd 'T' HH:mm:ss.SSSZ").

{"time": "2021-02-26T15:00:00.000Z"}

This format shows as:

2021-02-25 03:00.00

For related information on the addDuration task, see the addDuration API reference.

See also the getTime API reference.


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.