xs:gMonth

The primitive type xs:gMonth represents a recurring month. It can be used to specify, for example, that year-end auditing occurs in October of every year. It does not represent a number of months; to represent that, use the xs:yearMonthDuration type instead.

The lexical representation of xs:gMonth is --MM. An optional time zone may be used, as described in "Time Zones" in Chapter 19. Table B-12 lists some values of this type.

Table B-12. Values of the xs:gMonth type

Values

Explanation

Valid

 
--06

June

Invalid

 
--06--

Because of an error in the first version of XML Schema, you will often see examples that use this format, but it is technically invalid

--15

The month must be a valid month

2006-06

The year cannot be specified

06

The two leading hyphens are required

--6

It must have two digits

 

An empty value or zero-length string is not permitted

Values of xs:gMonth can be tested for equality (or inequality) with other values of the same type, but you cannot compare them 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:gMonth returns an xs:gMonth value of --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.