Duration functions
Note
These functions can be used when converting between numeric and duration data.
| Function | Description |
|---|---|
duration::days() | Counts how many days fit in a duration |
duration::hours() | Counts how many hours fit in a duration |
duration::max | Constant representing the greatest possible duration |
duration::micros() | Counts how many microseconds fit in a duration |
duration::millis() | Counts how many milliseconds fit in a duration |
duration::mins() | Counts how many minutes fit in a duration |
duration::nanos() | Counts how many nanoseconds fit in a duration |
duration::secs() | Counts how many seconds fit in a duration |
duration::weeks() | Counts how many weeks fit in a duration |
duration::years() | Counts how many years fit in a duration |
duration::from_days() | Converts a numeric amount of days into a duration that represents days |
duration::from_hours() | Converts a numeric amount of hours into a duration that represents hours |
duration::from_micros() | Converts a numeric amount of microseconds into a duration that represents microseconds |
duration::from_millis() | Converts a numeric amount of milliseconds into a duration that represents milliseconds |
duration::from_mins() | Converts a numeric amount of minutes into a duration that represents minutes |
duration::from_nanos() | Converts a numeric amount of nanoseconds into a duration that represents nanoseconds |
duration::from_secs() | Converts a numeric amount of seconds into a duration that represents seconds |
duration::from_weeks() | Converts a numeric amount of weeks into a duration that represents weeks |
duration::days
The duration::days function counts how many days fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::hours
The duration::hours function counts how many hours fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::max
The duration::max constant represents the greatest possible duration that can be used.
Some examples of the constant in use:
duration::micros
The duration::micros function counts how many microseconds fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::millis
The duration::millis function counts how many milliseconds fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::mins
The duration::mins function counts how many minutes fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::nanos
The duration::nanos function counts how many nanoseconds fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::secs
The duration::secs function counts how many seconds fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::weeks
The duration::weeks function counts how many weeks fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::years
The duration::years function counts how many years fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_days
The duration::from_days function counts how many years fit into a duration.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_hours
The duration::from_hours function converts a numeric amount of hours into a duration that represents hours.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_micros
The duration::from_micros function converts a numeric amount of microseconds into a duration that represents microseconds.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_millis
The duration::from_millis function converts a numeric amount of milliseconds into a duration that represents milliseconds.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_mins
The duration::from_mins function converts a numeric amount of minutes into a duration that represents minutes.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_nanos
The duration::from_nanos function converts a numeric amount of nanoseconds into a duration that represents nanoseconds.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_secs
The duration::from_secs function converts a numeric amount of seconds into a duration that represents seconds.
The following example shows this function, and its output, when used in a RETURN statement:
duration::from_weeks
The duration::from_weeks function converts a numeric amount of weeks into a duration that represents weeks.
The following example shows this function, and its output, when used in a RETURN statement:
Method chaining
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.
This is particularly useful for readability when a function is called multiple times.