- 18 Oct 2024
-
DarkLight
-
PDF
addDuration (time)
- Updated on 18 Oct 2024
-
DarkLight
-
PDF
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 explained 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 providedinputTime
. 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 theGet time
task, which is located elsewhere in the workflow. The reference variable istime
. - 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 theinputTime
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 resultingnewTime
would be "2020-06-05".
Example 2
In this second example:
- The
inputTime
property is provided by theGet time
task, which is located elsewhere in the workflow. The reference variable istime
. - Notice that the
time
variable provided by theGet time
reference task should have anoffsetDuration
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 is the result of adding 24 hours to theinputTime
value that was provided.
Example 3
In this last IAP example:
- The
inputTime
property is provided by theGet time
task, which is located elsewhere in the workflow. The reference variable istime
. - The
time
variable provided by theGet time
reference task should have anoffsetDuration
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 theinputTime
value that was provided.
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
Related Information
For related information on the addDuration task, see the addDuration API reference.
See also the getTime API reference.