diffTime
Description
Returns the duration between two timestamps as an interval.
The result is not the absolute difference:
- Positive if
to > from - Negative if
to < from
Syntax
Like many functions in DataPrime, diffTime supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
| to | timestamp | true | The timestamp to compare (typically the later time) |
| from | timestamp | true | The timestamp to compare (typically the earlier time) |
Example
Use case: Measure process duration
A document contains start and end timestamps for a process. Use diffTime to compute the elapsed interval.
Example query
Example output
{
"processing_start_time": 1728636298,
"processing_end_time": 1728636358,
"time_taken_duration": "50s"
}
Theme
Light