Converts $string-var (a string in the gYearMonth format) to the gYearMonth 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 gYearMonth format, the following error is reported:
Could not cast "invalid_gYearMonth_string" to type [gYearMonth@htttp://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_gYearMonth_string is the string not valid to the time format, for example: "2003-8".
xs:gYearMonth(xs:string $string-var) —> xs:gYearMonth
Represents a string with the month and year specified with one of the following formats: |
|||
Positive time zone offset. This option is optional. If a plus or minus is not specified, + is assumed. |
|||
Returns the specified month and year in the gYearMonth data type.
Invoking gYearMonth("2003-08") returns a gYearMonth value corresponding to August 2003, as shown in the following example query:
<result>{xs:gYearMonth("2003-08")}</result>
The preceding query, generates the following XML result:
<result>2003-08</result>
Invoking gYearMonth("2003-08Z") returns a gYearMonth value corresponding to August 2003 in the UTC time zone, as shown in the following example query:
<result>{xs:gYearMonth("2003-08Z")}</result>
The preceding query, generates the following XML result:
<result>2003-08Z</result>
Invoking gYearMonth("2003-8") outputs an error because the month is not specified using two digits.
For example, the following example query:
<result>{xs:gYearMonth("2003-8")}</result>
Error occurred while executing XQuery: Could not cast "2003-8" to type [gYearMonth@http://www.w3.org/2001/XMLSchema]
W3C gYearMonth data type description