duration(end_timestamp: numeric or variant) -> duration
duration(start_timestamp: timestamp, end_timestamp: timestamp) -> duration

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.

Domain

This is a scalar function (calculates a single output value for a single input row).

Categories

Examples

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.

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.