Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Ftime%2Faddinterval.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Ftime%2Faddinterval.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `addInterval`

## Description

Returns the sum of two intervals as a single interval value.

For example, adding an interval of `1d` (one day) to another `1d` produces `2d` (two days).

Note

This function also supports negative intervals. For example, `1d + -1h` results in `23h`, following standard arithmetic rules where adding a negative is equivalent to subtraction.

## Syntax

Like many functions in DataPrime, `addInterval` supports<!-- --> [two notations](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
addInterval(left: interval, right: interval): interval
```

```
(left: interval).addInterval(right: interval): interval
```

## Arguments

| Name    | Type       | Required | Description                |
| ------- | ---------- | -------- | -------------------------- |
| `left`  | `interval` | **true** | The first interval to add  |
| `right` | `interval` | **true** | The second interval to add |

## Example

**Use case: Compute total processing time across different units**

A document contains both a loading duration in milliseconds and processing timestamps in seconds. To compute the full duration of the transaction, convert the millisecond value to an interval, compute the processing interval, and add them together.

```
{

    "loading_duration_ms": 5432,

    "processing_start_time": 1728582889,

    "processing_end_time": 1728582899

}
```

### Example query

* Function notation
* Method notation

```
create processing_duration from diffTime(processing_start_time, processing_end_time)

| create total_duration from addInterval(loading_duration_ms.toInterval('ms'), processing_duration)
```

```
create processing_duration from processing_start_time.diffTime(processing_end_time)

| create total_duration from addInterval(loading_duration_ms.toInterval('ms'), processing_duration)
```

### Example output

```
{

    "loading_duration_ms": 5432,

    "processing_start_time": 1728582889,

    "processing_end_time": 1728582899,

    "processing_duration": "10s",

    "total_duration": "15432ms"

}
```
