subtractTime
Description
Returns a timestamp reduced by a given interval.
Note
Equivalent to addTime(t, -i)
or t - i
, where t
is a timestamp and i
is an interval.
Syntax
Like many functions in DataPrime, subtractTime
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
t | timestamp | true | The timestamp to modify |
i | interval | true | The interval to subtract from the timestamp |
Example
Use case: Calculate process start time
A log records a completion timestamp and a process duration in seconds. Convert the duration to an interval and subtract it from the completion time to calculate when the process started.
Output
{
"timestamp": 1728763337000000000,
"time_taken_s": 500,
"event": "COMPLETE",
"time_started": 1728762837000000000
}
Theme
Light