xs:gYear
The primitive type xs:gYear
represents a specific year. The lexical representation of xs:gYear
is YYYY
. A preceding minus sign (−) can be used to represent years before 0001. An optional time zone may be used, as described in "Time Zones" in Chapter 19. Table B-14 lists some values of the xs:gYear
type.
Table B-14. Values of the xs:gYear type
Values |
Explanation |
---|---|
Valid | |
2006 |
2006 |
2006-08:00 |
2006, U.S. Pacific Time |
12006 |
The year 12006 |
0922 |
The year 922 |
−0073 |
73 B.C. |
Invalid | |
99 |
It must have at least four digits |
922 |
It must have at least four digits; leading zeros can be added |
An empty value or zero-length string is not permitted |
Values of xs:gYear
can be tested for equality (or inequality) with other values of the same type, but they cannot be compared using the operators <
, <=
, >
, or >=
.
Values of this type can be cast from the xs:date
and xs:dateTime
types. For example, the expression xs:date("2006-05-30") cast as xs:gYear
returns an xs:gYear
value of 2006
. They can also be cast to and from xs:string
and xs:untypedAtomic
.
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.