Datetime
An ISO 8601 compliant date and time type.
Syntax
A datetime literal consists of a date fragment and a time fragment, separated by the character T.
The date fragment consists of the following values, separated by a -:
-
either a four-digit year or a sign with any number of digits for the year (e.g.
+252525meaning year 252525), -
a two-digit month of the year,
-
and a two-digit day of that month.
The time fragment consists of the following values, separated by ::
-
a two-digit hour between
00and24, -
a two-digit minute between
00and59, -
a two-digit second between
00and59with up to nine digits after the decimal point.
2024-03-30T12:00:00
1920-09-21T09:00:00
#!test[read]
#{{
match
let $x = 2024-03-30T12:00:00;
let $y = 1920-09-21T09:00:00;
#}}
+20000-01-01T10:30:00.000
+900-09-21T19:59:59.358
#!test[read]
#{{
match
let $x = +20000-01-01T10:30:00.000;
let $y = +900-09-21T19:59:59.358;
#}}
In expressions
A difference between two datetime values is a duration such that when it is added to the earlier datetime, it produces the later datetime. See the Duration type reference for more information about datetime-duration arithmetic. The time portion of the result is always under 24 hours.
2024-03-30T12:00:00 - 2020-09-21T09:00:00 == P3Y6M9DT3H
2020-09-21T09:00:00 + P3Y6M9DT3H == 2024-03-30T12:00:00