Orchestrator

Dynamic Date/Time Calculation

Article content is machine translated from English to other languages by Phrase Translate.

Workflows may require a date that is fetched at the runtime rather than hard-coded. This can be provided with sprig functions.

Sprig documentation references:

Caution

Syntax used in the documentation at masterminds differs from what is used in Orchestrator. E.g., now | date "2006-01-02" becomes {{sprig.date("2006-01-02", sprig.now())}}

Use cases

Getting the current time/date

  • To just get the date at the time of the particular workflow execution, in any parameter field, enter:

    {{sprig.now()}}.

  • At runtime, the date is returned in this format:

    "2023-02-24 11:33:01.819987888 +0000 UTC m=+77750.651866821"

Formatting a date

  • To format a date, use: sprig.date(“FORMAT_STRING”, “DATE”)

    Provide a string with the format required for the date referencing this standard date: Mon Jan 2 15:04:05 MST 2006  (MST is GMT-0700)

  • Examples:

    {{sprig.date("02.01.2006 - 15:04", sprig.now())}} results in “24.02.2023 - 11:36” (at time of writing).

    To provide the date in the format required by TMS API ("2019-08-24T14:15:22Z") invoke {{sprig.date("2006-01-02T15:04:05Z", sprig.now())}}

Modifying a date

  • To perform a calculation based the example sprig.now(), use sprig.dateModify(“MODIFY_VALUE”, “DATE”).

  • Example:

    {{sprig.dateModify("24h", sprig.now())}} (run on Feb 24th, 12:43) results in "2023-02-25 11:43:48.073101611 +0000 UTC m=+164796.904980545" - 24 hours after initial date.

  • Combinations can be used.

    To get the time and date of the execution, plus 24 hours, formatted for TMS API, pass this expression to the given field:

    {{sprig.date("2006-01-02T15:04:05Z", sprig.dateModify("24h", sprig.now()))}}

    Resulting in "2023-02-25T11:50:50Z" (when run on Feb 24th, 11:50 hrs).

  • The value by which the date should be modified can be given in hours, with “-” if the value should be subtracted. Fractions such as “-1.5h” can also be used.

Was this article helpful?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.