---
title: parseInterval
description: |
  Returns an interval parsed from a string representation such as `2d` or `35m10s`, enabling calculations with durations.

  A valid string must follow these rules:

  * Format: `NdNhNmNsNmsNusNns` where `N` is a non-negative integer
  * At least one time unit must be present
  * No unit may appear more than once (`1d2d` is invalid)
  * Units must appear in descending order (days → nanoseconds). `1d1s` is valid; `1s1d` is not
  * A leading `-` is allowed to indicate a negative interval (the only valid position for `-`)
  * If the format is invalid, the function returns `null`
url: https://coralogix.com/docs/dataprime/language-reference/functions-reference/time/parseinterval/
product: dataengine
feature: DataPrime Language
feature_id: dataprime-language
feature_identifier: dataengine/dataprime-language
last_updated: '2026-10-21'
---

# `parseInterval`

## Description

Returns an interval parsed from a string representation such as `2d` or `35m10s`, enabling calculations with durations.

A valid string must follow these rules:

* Format: `NdNhNmNsNmsNusNns` where `N` is a non-negative integer
* At least one time unit must be present
* No unit may appear more than once (`1d2d` is invalid)
* Units must appear in descending order (days → nanoseconds). `1d1s` is valid; `1s1d` is not
* A leading `-` is allowed to indicate a negative interval (the only valid position for `-`)
* If the format is invalid, the function returns `null`

## Syntax

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

* Function notation
* Method notation

```
parseInterval(string: string): interval
```

```
(string: string).parseInterval(): interval
```

## Arguments

| Name     | Type     | Required | Description                          |
| -------- | -------- | -------- | ------------------------------------ |
| `string` | `string` | **true** | The string to parse into an interval |

## Example

**Use case: Parse an interval string and add it to a timestamp**

A log includes a timestamp and a `completed_in` field with a duration string. Parse the string to an interval, then add it to the timestamp to calculate the job’s completion time.

```
{

  "timestamp": 1728763337,

  "job_name": "BUILD_VIDEO",

  "completed_in": "35m10s"

}
```

### Example query

* Function notation
* Method notation

```
create completed_time from addTime(timestamp, parseInterval(completed_in))
```

```
create completed_time from timestamp.addTime(completed_in.parseInterval())
```

### Example output

```
{

  "timestamp": 1728763337,

  "job_name": "BUILD_VIDEO",

  "completed_in": "35m10s",

  "completed_time": 1728765447

}
```
