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, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
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
Example output
{
"loading_duration_ms": 5432,
"processing_start_time": 1728582889,
"processing_end_time": 1728582899,
"processing_duration": "10s",
"total_duration": "15432ms"
}