Schema Central > XML Schema 1.0 > xsd:yearMonthDuration
Advanced search
Need XML Help?

Recommended Reading:

Definitive XML Schema

 

Web Service Contract Design and Versioning for SOA

 

Advanced XML Applications

 

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

Examples

Valid valuesComment
P2Y6M2 years, 6 months
P20M20 months (the number of months can be more than 12)
P0Y20M20 months (0 is permitted as a number, but is not required)
P0Y0 years
-P60Yminus 60 years
Invalid valuesComment
P2Y6M5DT12H35M30Scomponents other than years or months are not allowed
P-20Mthe minus sign must appear first
P20MT"T" must not be present
P1YMno value is specified for months, so "M" must not be present
P15.5Ynumbers cannot be expressed as a decimal
1Y2M"P" must always be present
P2M1Yyears must appear before months
Pat least one number and designator are required
an empty value is not valid, unless xsi:nil is used

Type Inheritance Chain

Site developed and hosted by Datypic, Inc.

Please report errors or comments about this site to contrib@functx.com