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.

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.