XSD Date and Time Data Type
- Previous Page XSD String
- Next Page XSD Numeric
The date and time data types are used to contain values with both date and time.
Date Data Type
The date data type is used to define dates.
Dates are defined using this format: "YYYY-MM-DD", where:
- YYYY represents the year
- MM represents the month
- DD represents the day number
Note:All components are required!
Here is an example of a date declaration in a schema:
<xs:element name="start" type="xs:date"/>
The elements in the document should look something like this:
<start>2002-09-24</start>
Time Zone
If you need to specify a time zone, you can also enter a date by adding a "Z" after the date using Coordinated Universal Time (UTC time) - for example:
<start>2002-09-24Z</start>
Or you can also specify an offset from world co-ordinated time by adding a positive or negative time after the date - for example:
<start>2002-09-24-06:00</start>
Or:
<start>2002-09-24+06:00</start>
Time Data Type
The time data type is used to define time.
Time is defined using the following format: "hh:mm:ss", where
- hh represents hours
- mm represents minutes
- ss represents seconds
Note:All components are required!
Here is an example of a time declaration in a schema:
<xs:element name="start" type="xs:time"/>
The elements in the document should look something like this:
<start>09:00:00</start>
Or something like this:
<start>09:30:10.5</start>
Time Zone
If you need to specify a time zone, you can also input a time using world co-ordinated time (UTC time) by adding a "Z" after the time - for example:
<start>09:30:10Z</start>
Or also, you can specify the offset from Coordinated Universal Time (UTC) by adding a positive or negative time after the time - for example, like this:
<start>09:30:10-06:00</start>
Or:
<start>09:30:10+06:00</start>
Date and Time Data Type
The date and time data type is used to define date and time.
Date and time are defined using the following format: "YYYY-MM-DDThh:mm:ss", where:
- YYYY represents the year
- MM represents the month
- DD represents the day
- T indicates the start of the required time part
- hh represents hours
- mm represents minutes
- ss represents seconds
Note:All components are required!
Here is an example of a date and time declaration in a schema:
<xs:element name="startdate" type="xs:dateTime"/>
The elements in the document should look something like this:
<startdate>2002-05-30T09:00:00</startdate>
Or something like this:
<startdate>2002-05-30T09:30:10.5</startdate>
Time Zone
If you need to specify a time zone, you can also input a date and time using world co-ordinated time (UTC time) by adding a "Z" after the date and time - for example:
<startdate>2002-05-30T09:30:10Z</startdate>
Or also, you can specify the offset from Coordinated Universal Time (UTC) by adding a positive or negative time after the time - for example, like this:
<startdate>2002-05-30T09:30:10-06:00</startdate>
Or:
<startdate>2002-05-30T09:30:10+06:00</startdate>
Duration Data Type
The duration data type is used to specify time intervals.
The time interval is specified in the following format: "PnYnMnDTnHnMnS", where:
- P represents the period (required)
- nY represents the number of years
- nM represents the number of months
- nD represents the number of days
- T represents the start of the time part (this option is required if you intend to specify hours, minutes, and seconds)
- nH represents the number of hours
- nM represents the number of minutes
- nS represents the number of seconds
Here is an example of a duration declaration in the schema:
<xs:element name="period" type="xs:duration"/>
The elements in the document should look something like this:
<period>P5Y</period>
The above examples represent a cycle of 5 years.
Or something like this:
<period>P5Y2M10D</period>
The above examples represent a cycle of 5 years, 2 months, and 10 days.
Or something like this:
<period>P5Y2M10DT15H</period>
The above examples represent a cycle of 5 years, 2 months, 10 days, and 15 hours.
Or something like this:
<period>PT15H</period>
The above examples represent a cycle of 15 hours.
Negative duration
To specify a negative duration, enter a minus sign before P:
<period>-P10D</period>
The above examples represent a cycle of negative 10 days.
Date and time data type
Name | Description |
---|---|
date | Define a date value |
dateTime | Define a date and time value |
duration | Define an interval of time |
gDay | A part of defining a date - day (DD) |
gMonth | A part of defining a date - month (MM) |
gMonthDay | A part of defining a date - month and day (MM-DD) |
gYear | A part of defining a date - year (YYYY) |
gYearMonth | A part of defining a date - year and month (YYYY-MM) |
time | Define a time value |
Restrictions on date data types
Restrictions that can be used with date data types:
- enumeration
- maxExclusive
- maxInclusive
- minExclusive
- minInclusive
- pattern
- whiteSpace
- Previous Page XSD String
- Next Page XSD Numeric