XSD Date and Time Data TypesDate and time data types are used for values that contain date and time. Date Data TypeThe date data type is used to specify a date. The date is specified in the following form "YYYY-MM-DD" where:
Note: All components are required! The following is an example of a date declaration in a schema:
<xs:element name="start" type="xs:date"/>
An element in your document might look like this:
<start>2002-09-24</start>
Time ZonesTo specify a time zone, you can either enter a date in UTC time by adding a "Z" behind the date - like this:
<start>2002-09-24Z</start>
or you can specify an offset from the UTC time by adding a positive or negative time behind the date - like this:
<start>2002-09-24-06:00</start> or <start>2002-09-24+06:00</start> Time Data TypeThe time data type is used to specify a time. The time is specified in the following form "hh:mm:ss" where:
Note: All components are required! The following is an example of a time declaration in a schema:
<xs:element name="start" type="xs:time"/>
An element in your document might look like this:
<start>09:00:00</start>
Or it might look like this:
<start>09:30:10.5</start>
Time ZonesTo specify a time zone, you can either enter a time in UTC time by adding a "Z" behind the time - like this:
<start>09:30:10Z</start>
or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
<start>09:30:10-06:00</start> or <start>09:30:10+06:00</start> DateTime Data TypeThe dateTime data type is used to specify a date and a time. The dateTime is specified in the following form "YYYY-MM-DDThh:mm:ss" where:
Note: All components are required! The following is an example of a dateTime declaration in a schema:
<xs:element name="startdate" type="xs:dateTime"/>
An element in your document might look like this:
<startdate>2002-05-30T09:00:00</startdate>
Or it might look like this:
<startdate>2002-05-30T09:30:10.5</startdate>
Time ZonesTo specify a time zone, you can either enter a dateTime in UTC time by adding a "Z" behind the time - like this:
<startdate>2002-05-30T09:30:10Z</startdate>
or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
<startdate>2002-05-30T09:30:10-06:00</startdate> or <startdate>2002-05-30T09:30:10+06:00</startdate> Duration Data TypeThe duration data type is used to specify a time interval. The time interval is specified in the following form "PnYnMnDTnHnMnS" where:
The following is an example of a duration declaration in a schema:
<xs:element name="period" type="xs:duration"/>
An element in your document might look like this:
<period>P5Y</period>
The example above indicates a period of five years. Or it might look like this:
<period>P5Y2M10D</period>
The example above indicates a period of five years, two months, and 10 days. Or it might look like this:
<period>P5Y2M10DT15H</period>
The example above indicates a period of five years, two months, 10 days, and 15 hours. Or it might look like this:
<period>PT15H</period>
The example above indicates a period of 15 hours. Negative DurationTo specify a negative duration, enter a minus sign before the P:
<period>-P10D</period>
The example above indicates a period of minus 10 days. Date and Time Data Types
Restrictions on Date Data TypesRestrictions that can be used with Date data types:
|
|