duration¶
Description¶
Convert one argument as a number of nanoseconds or a timestamp, or two arguments as start or stop timestamps, to a duration. Numbers are input in nanoseconds.
Return type¶
duration
Domain¶
This is a scalar function (calculates a single output value for a single input row.)
Categories¶
Usage¶
duration( start_timestamp [ , end_timestamp ] )
Argument |
Type |
Required |
Multiple |
Constant |
---|---|---|---|---|
start_timestamp |
convertible to timestamp |
Required |
Only one |
Variable |
end_timestamp |
timestamp |
Optional |
Only one |
Variable |
Examples¶
make_col fromTime:parse_isotime("2022-04-20T16:20:00Z"), toTime:parse_isotime("2022-04-20T16:20:02")
make_col dur:duration(fromTime, toTime)
Creates two columns fromTime
and toTime
as parsed time stamps, and then calculates the duration between these two timestamps into dur
.
In this case, the duration will be 2 seconds. Note that the start time is the first argument.
make_col someNanos:123000
make_col dur:duration(someNanos)
Creates the column someNanos
that contains the integer value 123000.
Converts this as number of nanoseconds to the duration column dur
. The duration will be 123 microseconds.