Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Ftime%2Faddtime.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%2Faddtime.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `addTime`

## Description

Returns a new timestamp by adding an interval to an existing timestamp.

Both `timestamp` and `interval` are first-class types in DataPrime, so ensure that the correct types are passed.

Note

Negative intervals are supported and act as subtraction. For example, adding `-1h` to a timestamp subtracts one hour.

## Syntax

Like many functions in DataPrime, `addTime` 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

```
addTime(t: timestamp, i: interval): timestamp
```

```
(t: timestamp).addTime(i: interval): timestamp
```

## Arguments

| Name | Type        | Required | Description                                    |
| ---- | ----------- | -------- | ---------------------------------------------- |
| `t`  | `timestamp` | **true** | The base timestamp to modify                   |
| `i`  | `interval`  | **true** | The interval to add (or subtract, if negative) |

## Example

**Use case: Compute an event’s end time from its start time and duration**

A log contains a `start_timestamp` field and a `duration` field in seconds. Convert the duration to an interval, then add it to the start time to calculate the event's `end_timestamp`.

```
{

  "start_timestamp": 1728582889,

  "duration": 120

}
```

### Example query

* Function notation
* Method notation

```
create end_timestamp from addTime(start_timestamp, duration.toInterval('s'))
```

```
create end_timestamp from start_timestamp.addTime(duration.toInterval('s'))
```

### Example output

```
{

  "start_timestamp": 1728582889,

  "duration": 120,

  "end_timestamp": 1728583009

}
```
