Temporal functions
Constructors
XTQL | SQL | Return type |
---|---|---|
|
Construct a date - e.g. |
|
|
Construct a single-field interval - e.g. Construct a multi-field interval - e.g. |
|
|
|
Constructs a period.
Verifies that |
|
Construct a time - e.g. |
|
|
Constructs a timestamp.
|
Temporal arithmetic
XTQL | SQL | Return type |
---|---|---|
|
|
date-time |
|
|
duration |
|
|
interval |
|
|
date-time |
|
|
duration |
|
|
interval |
|
|
duration |
|
|
interval |
|
|
duration |
|
|
interval |
|
|
duration |
|
|
interval |
Note
|
|
Current time
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 tosubmit-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
Periods in XTDB are represented as a struct with a :start
and :end
timestamp.
Most of these 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
|
Miscellaneous
XTQL |
SQL |
|
|
|
Truncates the date-time to the given time-unit, which must be one of |
|
|
Extracts the given field from the date-time, which must be one of |