parse_duration

parse_duration(value: string) -> duration

Given a string describing the duration between two points in time, convert it to a duration.

Example duration strings: "2h 30m", "-1.5m", "22µs"

The string should be of the form: <optional minus sign> (<time> <interval>)+. Negative durations are specified by prepending a minus sign (like "-2h30m"). <time> must be a decimal. <interval> must be one of the following (case-insensitive):

IntervalAbbreviations/Variations
weekw, wk, weekofyear, woy, wy, weeks
dayd, dd, days, daysofmonth
hourh, hh, hr, hrs, hours
minutem, mi, min, mins, minutes
seconds, sec, secs, seconds
millisecondms, msec, msecs, milliseconds
microsecondus, µs, usec, usecs, µsec, µsecs, microseconds
nanosecondns, nsec, nanosec, nsecond, nanosec, nseconds, nanoseconds

Domain

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

Categories

Examples

make_col dur:parse_duration(durstr)

Assuming there's a string input column durstr with duration strings, outputs the corresponding duration objects (which is represented as an integer number of nanoseconds).

durstrdur
1.5m90000000000
22µs22000
2h30m9000000000000
2 hours 3 minutes 4 seconds7384000000000
42 jupiters 1 sunNULL
42x24yNULL
42NULL
wNULL