# $addDate

`$addDate` operator lets you **modify** date and datetimes. You can use this in any [<mark style="color:blue;">**Expression Object**</mark>](/flow-builder/cql-cosmocloud-query-language/building-expressions.md).

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

## Syntax

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

### Properties

| Field                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Required |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| \<date\_like\_obj>    | <p>The <code>\<date\_like\_obj></code> expression can be any valid <a href="/pages/E96SHGHwhXp256hQZFJ6"><mark style="color:blue;"><strong>expression</strong></mark></a> as long as it resolves to a <strong>epoch timestamp</strong> (seconds or milliseconds), or to <strong>datetime</strong> objects.</p><p></p><p>It can also be a <strong>Magical Autocomplete</strong>.<br><br>The epoch timestamp can be both in seconds as well as millisecond.</p> | true     |
| unit                  | It can be either **DAY** or **WEEKS**                                                                                                                                                                                                                                                                                                                                                                                                                         | true     |
| \<change\_difference> | <p>The <code>\<change\_difference></code> expression can be any valid <a href="/pages/E96SHGHwhXp256hQZFJ6"><mark style="color:blue;"><strong>expression</strong></mark></a> as long as it resolves to a number.</p><p></p><p>The value by which you want to add or substract days/weeks from the <code>startDate</code>.</p>                                                                                                                                 | 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)

```json
{
    "$addDate": {
        "startDate": 1709796918,
        "unit": "DAY",
        "amount": 1
    }
}
```

The above expression returns **1709883318**.

### Timestamp in epoch (milliseconds)

```json
{
    "$addDate": {
        "startDate": 1709796918000,
        "unit": "DAY",
        "amount": 1
    }
}
```

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.

```json
{
    "$addDate": {
        "startDate": datetime(2024, 03, 20),
        "unit": "WEEK",
        "amount": 1
    }
}
```

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cosmocloud.io/flow-builder/cql-cosmocloud-query-language/building-expressions/usdadddate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
