# xs:gMonth

Converts $string-var (a string in the gMonth format) to the gMonth data type.

If the value of $string-var is the empty sequence, the empty sequence is returned.The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

If the value of $string-var is not valid to the gMonth format, the following error is reported:

Could not cast "invalid_gMonth_string" to type [gMonth@htttp://www.w3.org/2001/XMLSchema] is displayed.

Where invalid_gMonth_string is the string not valid to the time format, for example: "08".

### Signatures

xs:gMonth(xs:string $string-var) —> xs:gMonth

### Arguments

Data Type | Argument | Description
--- | --- | ---
xs:string | $string-var | Represents a string with the month and day specified with one of the following formats: --MM-- --MM--Z --MM--+hh:mm --MM---hh:mm
|  | -- | Beginning prefix.
|  | MM | Month (as a number).
|  | -- | Separator.
|  | + | Positive time zone offset. (Optional) If a plus or minus is not specified, + is assumed.
|  | - | Negative time zone offset. (Optional)
|  | hh | Number of hours that the time zone differs from UTC.
|  | mm | Number of minutes that the time zone differs from UTC.
|  | Z | Indicates that the time corresponds to the UTC time zone.

### Returns

Returns the specified month in the gMonth data type.

### Examples

#### Simple

Invoking gMonth("--08--") returns a gMonth value corresponding to the month of August, as shown in the following example query:

    <result>{xs:gMonth("--08--")}</result>

The preceding query, generates the following XML result:

    <result>--08--</result>

#### UTC Time Zone

Invoking gMonth("--08--Z") returns a gMonth value corresponding to the month of August in the UTC time zone, as shown in the following example query:

    <result>{xs:gMonth("--08--Z")}</result>

The preceding query, generates the following XML result:

    <result>--08--Z</result>

#### Error—Incorrect Format

Invoking gMonth("08") outputs an error because the -- prefix is missing.

For example, the following example query:

    <result>{xs:gMonth("08")}</result>

Produces the following error:

    Error occurred while executing XQuery: Could not cast "08" to type [gMonth@http://www.w3.org/2001/XMLSchema]

Related Topics

W3C gMonth data type description