xsd:yearMonthDuration
The type xsd:yearMonthDuration
represents a duration of time expressed as a number of years and months. The format of xsd:yearMonthDuration
is PnYnM
, where P
is a literal value that starts the expression, nY
is the number of years followed by a literal Y
, nM
is the number of months followed by a literal M
. The following rules apply to xsd:yearMonthDuration
values:
Either of these numbers and corresponding designators may be absent if they are equal to 0, but at least one number and designator must appear.
The numbers may be any unsigned integer.
A minus sign may appear before the
P
to specify a negative duration.
Note that this type was added to the XML Schema namespace as a result of XPath 2.0. It was not in the original XML Schema 1.0 specification and is therefore not supported for use in XML Schema 1.0 schemas.
Simple Type Information
Namespace: http://www.w3.org/2001/XMLSchema
Schema Document: datatypes.xsd
Content
- Based on xsd:duration
- White Space: collapse (Defined in type xsd:duration)
Examples
Valid values | Comment |
---|---|
P2Y6M | 2 years, 6 months |
P20M | 20 months (the number of months can be more than 12) |
P0Y20M | 20 months (0 is permitted as a number, but is not required) |
P0Y | 0 years |
-P60Y | minus 60 years |
Invalid values | Comment |
P2Y6M5DT12H35M30S | components other than years or months are not allowed |
P-20M | the minus sign must appear first |
P20MT | "T " must not be present |
P1YM | no value is specified for months, so "M " must not be present |
P15.5Y | numbers cannot be expressed as a decimal |
1Y2M | "P " must always be present |
P2M1Y | years must appear before months |
P | at least one number and designator are required |
an empty value is not valid, unless xsi:nil is used |
Type Inheritance Chain
- xsd:anySimpleType
- restricted by xsd:duration
- restricted by xsd:yearMonthDuration
- restricted by xsd:duration