Duration functions
These functions can be used when converting between numeric and duration data.
duration::days
The duration::days function counts how many days fit into a duration.
API DEFINITION
duration::days(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::days(3w);
duration::hours
The duration::hours function counts how many hours fit into a duration.
API DEFINITION
duration::hours(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::hours(3w);
duration::max
Available since: v2.3.0
The duration::max constant represents the greatest possible duration that can be used.
API DEFINITION
duration::max -> duration
Some examples of the constant in use:
duration::max;
duration::max + 1ns;
100y IN 0ns..duration::max
Output
584942417355y3w5d7h15s999ms999µs999ns
'Failed to compute: "584942417355y3w5d7h15s999ms999µs999ns + 1ns", as the operation results in an arithmetic overflow.'
true
duration::micros
The duration::micros function counts how many microseconds fit into a duration.
API DEFINITION
duration::micros(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::micros(3w);
duration::millis
The duration::millis function counts how many milliseconds fit into a duration.
API DEFINITION
duration::millis(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::millis(3w);
duration::mins
The duration::mins function counts how many minutes fit into a duration.
API DEFINITION
duration::mins(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::mins(3w);
duration::nanos
The duration::nanos function counts how many nanoseconds fit into a duration.
API DEFINITION
duration::nanos(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::nanos(3w);
duration::secs
The duration::secs function counts how many seconds fit into a duration.
API DEFINITION
duration::secs(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::secs(3w);
duration::weeks
The duration::weeks function counts how many weeks fit into a duration.
API DEFINITION
duration::weeks(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::weeks(3w);
duration::years
The duration::years function counts how many years fit into a duration.
API DEFINITION
duration::years(duration) -> number
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::years(300w);
duration::from_days
The duration::from_days function counts how many years fit into a duration.
API DEFINITION
duration::from_days(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_days(3);
duration::from_hours
The duration::from_hours function converts a numeric amount of hours into a duration that represents hours.
API DEFINITION
duration::from_hours(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_hours(3);
duration::from_micros
The duration::from_micros function converts a numeric amount of microseconds into a duration that represents microseconds.
API DEFINITION
duration::from_micros(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_micros(3);
duration::from_millis
The duration::from_millis function converts a numeric amount of milliseconds into a duration that represents milliseconds.
API DEFINITION
duration::from_millis(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_millis(3);
duration::from_mins
The duration::from_mins function converts a numeric amount of minutes into a duration that represents minutes.
API DEFINITION
duration::from_mins(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_mins(3);
duration::from_nanos
The duration::from_nanos function converts a numeric amount of nanoseconds into a duration that represents nanoseconds.
API DEFINITION
duration::from_nanos(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_nanos(3);
duration::from_secs
The duration::from_secs function converts a numeric amount of seconds into a duration that represents seconds.
API DEFINITION
duration::from_secs(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_secs(3);
duration::from_weeks
The duration::from_weeks function converts a numeric amount of weeks into a duration that represents weeks.
API DEFINITION
duration::from_weeks(number) -> duration
The following example shows this function, and its output, when used in a RETURN statement:
RETURN duration::from_weeks(3);
Method chaining
Available since: v2.0.0
Method chaining allows functions to be called using the . dot operator on a value of a certain type instead of the full path of the function followed by the value.
duration::mins(2d6h);
2d6h.mins();
Response
3240
This is particularly useful for readability when a function is called multiple times.
duration::mins(duration::from_millis(98734234));
duration::from_millis(98734234).mins();
Response
1645