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(end_timestamp)

Argument

Type

Optional

Repeatable

Restrictions

end_timestamp

numeric or variant

no

no

none

duration(start_timestamp, end_timestamp)

Argument

Type

Optional

Repeatable

Restrictions

start_timestamp

timestamp

no

no

none

end_timestamp

timestamp

no

no

none

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.