Task References

On this page:

addDuration (time)

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 use the example of adding 6 months to a poll record. Using this task, the automation run would generate a result similar to the following: "Last poll ocurred on 01JAN, next poll will occur on 01JUN".

Properties

Incoming Type Description
inputTime Object Required. A timestamp provided from the result of a previous automation task.
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).

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.


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.

Examples

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.

    addDuration01

  • 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".

Example 2

In this IAP 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.

    addDuration02

  • The outgoing newTime variable will be the result of adding 24 hours to the inputTime value that was provided.

Example 3

In this 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.

    addDuration03

  • The outgoing newTime variable will be the result of adding 6 months and 4 hours to the inputTime value that was provided.