Returns a new period from from
to to
.
-
from
must be strictly less thanto
.
Note
|
For information on what temporal types we support and how to construct temporal literals, see temporal types. |
XTQL | SQL | Return type |
---|---|---|
|
|
date-time |
|
|
duration |
|
|
interval |
|
|
date-time |
|
|
duration |
|
|
interval |
|
|
integer (number of days elapsed) |
|
|
duration |
|
|
interval |
|
|
duration |
|
|
interval |
|
|
duration |
|
|
interval |
Note
|
|
XTDB allows fine-grained control over user requests for the 'current time', to allow for fully repeatable queries.
The wall-clock time of a query is fixed when the query starts.
It can be explicitly specified by passing :current-time
to the query options; otherwise, it will snapshot the current-time of the XTDB node.
The wall-clock time of a query within a transaction is fixed to the system-time of the transaction, as recorded by the transaction log (or overridden using the :system-time
option to submit-tx
).
Each transaction/query has a default time-zone, which defaults to the time-zone of the XTDB node’s JVM unless overridden in the query options (default-tz
).
XTQL | SQL | |
---|---|---|
|
|
Returns the current wall-clock date/time as a timestamp with time-zone. |
|
|
Returns the current UTC wall-clock date. |
|
|
Returns the current UTC wall-clock time. |
|
|
Returns the current wall-clock date/time as a local timestamp (without time-zone), as in the query’s time-zone. |
|
|
Returns the current wall-clock time as a local time (without time-zone), as in the query’s time-zone. |
Periods in XTDB are represented as a pair of timestamps with inclusive start and exclusive end ('closed-open').
They are constructed with the PERIOD
function:
XTQL | SQL | |
---|---|---|
|
|
Returns a new period from
|
Most of the below period comparators have 'strictly' and 'immediate' variants.
'strictly' variants check that the two periods don’t meet - e.g. precedes?
will return true if the earlier period ends at the same time the second period starts; strictly-precedes?
will return false.
'immediately' variants check that the two periods do meet.
These functions will return null if any of their arguments are null.
XTQL | SQL | |
---|---|---|
|
|
Returns true iff
|
|
|
Returns true iff the two periods are equal
|
|
|
Returns true iff
|
|
|
Returns true iff
|
|
|
Returns true iff
|
|
|
Returns true iff
|
|
|
Returns true iff
|
The below functions operate on periods:
XTQL | SQL | |
---|---|---|
|
|
Returns the lower bound of the provided period, or null if it infinite. |
|
|
Returns true iff the lower bound of the provided period is infinite. |
|
|
Returns the upper bound of the provided period, or null if it is infinite. |
|
|
Returns true iff the upper bound of the provided period is infinite. |
|
|
Returns the intersection of the two periods. e.g.:
|
XTQL |
SQL |
|
|
|
Truncates the date-time to the given time-unit, which must be one of |
|
|
Truncates a timezone aware date-time to the given time-unit, which must be one of |
|
|
Truncates the given interval to the given time-unit, which must be one of |
|
Bins the given timestamp within the given 'stride' interval, optionally relative to the given origin (or '1970-01-01' if not supplied). e.g. |
|
|
Aligns the given period within bins of the given 'stride' interval, optionally relative to the given origin (or '1970-01-01' if not supplied). Returns an array of structs, each containing the e.g.
|
|
|
|
Extracts the given field from the date-time. Field must be one of |
|
|
Extracts the given field from the date. Field must be one of |
|
|
Extracts the given field from the time. Field must be one of |
|
|
Extracts the given field from the interval. Field must be one of |
|
|
Returns an interval representing the difference between two date-times - subtracting the second value from the first. Works for any combination of date times, date times with time zone identifiers, or dates. |