xs:date
The primitive type xs:date
represents a date of the Gregorian calendar. The lexical representation of xs:date
is YYYY-MM-DD
where YYYY
represents the year, MM
the month, and DD
the day. The year value has to be at least four digits, but it can be more than four digits to represent years later than 9999. However, XQuery implementations are not required to support more than four digits. A preceding minus sign (-) can be used to represent years before 0001. A time zone can be added to the end, as described in "Time Zones" in Chapter 19.
Values of type xs:date
can be cast to and from xs:dateTime
,
as described in the section on xs:dateTime
. You can obtain the current date using the current-date
function, which returns a value of type xs:date
.
Table B-3 lists some values of the xs:date
type. For more information on working with dates, see Chapter 19.
Table B-3. Values of the xs:date type
Values |
Explanation |
---|---|
Valid | |
2006-05-03 |
May 3, 2006 |
2006-05-03-05:00 |
May 3, 2006, U.S. Eastern Standard Time, which is five hours behind Coordinated Universal Time (UTC) |
2006-05-03Z |
May 3, 2006, Coordinated Universal Time (UTC) |
Invalid | |
2006/05/03 |
Slashes are not allowed as separators |
05-03-2006 |
The value must be in |
2006-09-31 |
The date must be valid (September has 30 days) |
An empty value or zero-length string is not permitted |
Get XQuery now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.