XSD Date and Time Data Type
- Previous Page XSD String
- Next Page XSD Numeric
Date and time data types are used to contain values that include both dates and times.
Date Data Type
The date data type is used to define dates.
The date is defined using this format: "YYYY-MM-DD", where:
- YYYY represents the year
- MM represents the month
- DD represents the number of days
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 input a date using world adjustment time (UTC time) by adding a "Z" after the date - for example:
<start>2002-09-24Z</start>
Or you can also specify an offset from world adjustment 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 (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 similar:
<start>09:30:10.5</start>
Time zone
If you need to specify a time zone, you can also input a time using world adjustment time (UTC time) by adding a "Z" after the time - for example:
<start>09:30:10Z</start>
Or you can also specify an offset from Coordinated Universal Time (UTC) by adding a positive or negative time after the time - for example:
<start>09:30:10-06:00</start>
Or:
<start>09:30:10+06:00</start>
Date-time data type (DateTime Data Type)
The date-time data type is used to define dates and times.
The date-time format is defined as follows: "YYYY-MM-DDThh:mm:ss", where:
- YYYY represents the year
- MM represents the month
- DD represents the day
- T represents the start of the required time components
- hh represents hours
- mm represents minutes
- ss represents seconds
Note:All components are required!
Here is an example of a date-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 similar:
<startdate>2002-05-30T09:30:10.5</startdate>
Time zone
If you need to specify a time zone, you can also enter a date and time using world adjustment time (UTC time) by adding a "Z" after the date and time - for example:
<startdate>2002-05-30T09:30:10Z</startdate>
Or you can also specify an offset from Coordinated Universal Time (UTC) by adding a positive or negative time after the time - for example:
<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.
Time intervals are specified in the following format: "PnYnMnDTnHnMnS", where:
- P indicates the period (required)
- nY indicates the number of years
- nM indicates the number of months
- nD indicates the number of days
- T indicates the start of the time part (this option is required if you intend to specify hours, minutes, and seconds)
- nH indicates the number of hours
- nM indicates the number of minutes
- nS indicates the number of seconds
Below 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 example indicates a cycle of 5 years.
Or something similar:
<period>P5Y2M10D</period>
The above example indicates a cycle of 5 years, 2 months, and 10 days.
Or something similar:
<period>P5Y2M10DT15H</period>
The above example indicates a cycle of 5 years, 2 months, 10 days, and 15 hours.
Or something similar:
<period>PT15H</period>
The above example indicates a cycle of 15 hours.
Negative duration
To specify a negative duration, enter a minus sign before P:
<period>-P10D</period>
The above example indicates a cycle of -10 days.
Date and time data type
Name | Description |
---|---|
date | Define a date value |
dateTime | Define a date and time value |
duration | Define a time interval |
gDay | A part of a date - Day (DD) |
gMonth | Define a Part of the Date - Month (MM) |
gMonthDay | Define a Part of the Date - Month and Day (MM-DD) |
gYear | Define a Part of the Date - Year (YYYY) |
gYearMonth | Define a Part of the Date - Year and Month (YYYY-MM) |
time | Define a Time Value |
Constraints (Restrictions) for Date Data Types
Constraints that Can Be Used with Date Data Types:
- enumeration
- maxExclusive
- maxInclusive
- minExclusive
- minInclusive
- pattern
- whiteSpace
- Previous Page XSD String
- Next Page XSD Numeric