subtractInterval
Description
Returns the result of subtracting one interval from another.
Note
Equivalent to addInterval(left, -right)
or left - right
.
Syntax
Like many functions in DataPrime, subtractInterval
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 interval to subtract from |
right | interval | true | The interval to subtract |
Example
Use case: Calculate idle time
A log tracks total time taken, as well as processing and loading durations. Subtract the sum of processing and loading from the total to compute idle time.
{
"event": "PROCESSING_COMPLETE",
"timestamp": 1728763337,
"total_time_taken": "1m",
"processing_time_taken": "30s",
"loading_time_taken": "28s"
}
Output
{
"event": "PROCESSING_COMPLETE",
"timestamp": 1728763337,
"total_time_taken": "1m",
"processing_time_taken": "30s",
"loading_time_taken": "28s",
"idle_time": "2s"
}
Theme
Light