xs:gYearMonth
The primitive type xs:gYearMonth represents a specific month. The lexical representation of xs:gYearMonth is YYYY-MM. 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-15 lists some values of the xs:gYearMonth type.
Table B-15. Values of the xs:gYearMonth type
|
Values |
Explanation |
|---|---|
|
Valid | |
2006-05 |
May 2006 |
2006-05-08:00 |
May 2006, U.S. Pacific Time |
|
Invalid | |
2006-5 |
The month must have two digits |
2006-13 |
The month must be a valid month |
|
An empty value or zero-length string is not permitted |
Values of xs:gYearMonth 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:gYearMonth returns an xs:gYearMonth value of 2006-05. They can also be cast to and from xs:string and xs:untypedAtomic.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access