The xs:yearMonthDuration
type represents a restriction of the xs:duration
type, with only year (Y
) and month (M
) components allowed. Its lexical representation is PnYnM
, where an uppercase P
starts the expression, and n
indicates the quantity of each component. For example, the value P3Y5M
represents a period of three years and five months. You can omit components whose quantity is zero, but at least one component is required.
All of the lexical rules for xs:duration
also apply to the xs:yearMonthDuration
type. This includes allowing a negative sign at the beginning of the value. Table B-21 lists some values of the xs:yearMonthDuration
type.
In previous versions of XQuery (including the Candidate Recommendation), yearMonthDuration
was prefixed with xdt:
instead of xs:
because it was in a different namespace. Some processors still support the previous namespaces for these types instead.
Unlike the xs:duration
type, the xs:yearMonthDuration
type is totally ordered, meaning that its values can be compared. For more information on working with durations, see Chapter 19.
Table B-21. Values of the xs:yearMonthDuration type
3.147.47.166