$addDate

$addDate operator lets you modify date and datetimes. You can use this in any Expression Object.

This operator can work on both epoch timestamps as well as datetime objects.

Syntax

{
    "$addDate": {
        "startDate": <date_like_obj>,
        "unit": "DAY" | "WEEKS"
        "amount": <change_difference>
    }
}

Properties

Field
Description
Required

<date_like_obj>

The <date_like_obj> expression can be any valid expression as long as it resolves to a epoch timestamp (seconds or milliseconds), or to datetime objects.

It can also be a Magical Autocomplete. The epoch timestamp can be both in seconds as well as millisecond.

true

unit

It can be either DAY or WEEKS

true

<change_difference>

The <change_difference> expression can be any valid expression as long as it resolves to a number.

The value by which you want to add or substract days/weeks from the startDate.

true

Returns

integer - If the startDate is of type integer (both milliseconds and seconds)

datetime - If the startDate is of type datetime

Examples

Timestamp in epoch (seconds)

The above expression returns 1709883318.

Timestamp in epoch (milliseconds)

The above expression returns 1709883318000.

With Magical Autocomplete

Let's say we have declared a variable temp in our API flow, which has a value of 6 currently.

The above expression would resolve to a result of datetime(2024, 03, 27).

Last updated