Articles in this section

dateAdd helper

Use {{dateAdd}} to add or subtract a specific time offset (in milliseconds) from a given date, optionally applying a time zone for the resulting ISO 8601 timestamp. Typical uses include adjusting a date by days/hours or converting a timestamp to a particular time zone.

Usage

{{dateAdd dateField offsetField timeZoneField}}
  • dateField (required): The date to be adjusted (e.g., a string like "2025-03-26T00:00:00Z", or a reference like record.orderDate).

  • offsetField (optional): Time offset in milliseconds. Prepend a minus sign (-) to subtract instead of add. For example, "86400000" = +1 day; "-86400000" = -1 day.

  • timeZoneField (optional): A valid time zone identifier (e.g., "America/New_York", "Asia/Hong_Kong"). If omitted, the output remains in UTC with no specific offset.

Note

Examples

  1. No offset or time zone

    {{dateAdd record.orderDate}}
    

    If record.orderDate is "2025-03-26T12:34:56Z", the output is "2025-03-26T12:34:56.000Z" in ISO 8601 UTC format.

  2. Adding one day

    {{dateAdd record.orderDate "86400000"}}
    

    If record.orderDate is "2025-03-26T12:34:56Z", adds 24 hours and returns "2025-03-27T12:34:56.000Z".

  3. Subtracting twelve hours

    {{dateAdd record.shipDate "-43200000"}}
    

    If record.shipDate is "2025-05-10T00:00:00Z", subtracts half a day, yielding "2025-05-09T12:00:00.000Z".

  4. Applying a time zone

    {{dateAdd record.orderDate "86400000" "Asia/Hong_Kong"}}
    

    If record.orderDate is "2025-03-26T00:00:00Z", adds 24 hours and shifts to Hong Kong time, resulting in "2025-03-27T08:00:00.000+08:00".

  5. Hard-coded date string

    {{dateAdd "Mon Nov 21 2019 20:00:00 GMT+0000"}}
    

    Outputs "2019-11-21T20:00:00.000Z" in ISO format.

Tip

  • Offset values must be in milliseconds (e.g., 86400000 for one day). Scientific notation (e.g., "1E6") is also supported.

  • Negative offsets (e.g., "-86400000") subtract that time from the given date.

  • Time zones use IANA identifiers (e.g., "America/Los_Angeles"). If you omit this parameter, the result is in UTC.

  • The final output always conforms to an ISO 8601 date-time string, with or without the explicit offset depending on whether timeZoneField is provided.