parse_duration¶
Description¶
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):
Interval |
Abbreviations/Variations |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return type¶
duration
Domain¶
This is a scalar function (calculates a single output value for a single input row.)
Categories¶
Usage¶
parse_duration(value)
Argument |
Type |
Optional |
Repeatable |
Restrictions |
---|---|---|---|---|
value |
string |
no |
no |
none |
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).
durstr |
dur |
---|---|
1.5m |
90000000000 |
22µs |
22000 |
2h30m |
9000000000000 |
2 hours 3 minutes 4 seconds |
7384000000000 |
42 jupiters 1 sun |
NULL |
42x24y |
NULL |
42 |
NULL |
w |
NULL |