XSD Date and TimeData Types
Date and time data types are used to contain date and time values.
Date Data Type
The date data type is used to define a date.
The date is defined using this format: "YYYY-MM-DD", where:
- YYYY indicates the year
- MM indicates the month
- DD indicates the day
Note:All components are required.
Below is an example of a date declaration in a schema:
The element in the document should look like this:
Timezone
To specify a timezone, you can also enter a date using Coordinated Universal Time (UTC time) by adding a "Z" after the date - like this:
Alternatively, you can specify an offset from UTC by adding a positive or negative time after the date - like this:
or
<start>2002-09-24+06:00</start>
h2>Time Data Type
The time data type is used to define a time.
Time is defined using the following format: "hh:mm:ss", where
- hh indicates the hour
- mm indicates the minute
- ss indicates the second
Note:All components are required!
Below is an example of a time declaration in a schema:
The element in the document should look like this:
or like this:
Timezone
To specify a timezone, you can also enter a time using Coordinated Universal Time (UTC time) by adding a "Z" after the time - like this:
Alternatively, you can specify an offset from UTC by adding a positive or negative time after the time - like this:
or
<start>09:30:10+06:00</start>
DateTime Data Type
The dateTime data type is used to define a date and time.
The dateTime is defined using the following format: "YYYY-MM-DDThh:mm:ss", where:
- YYYY indicates the year
- MM indicates the month
- DD indicates the day
- T indicates the start of the required time section
- hh indicates the hour
- mm indicates the minute
- ss indicates the second
Note:All components are required!
Below is an example of a dateTime declaration in a schema:
The element in the document should look like this:
or like this:
Timezone
To specify a timezone, you can also enter a dateTime using Coordinated Universal Time (UTC time) by adding a "Z" after the dateTime - like this:
Alternatively, you can specify an offset from UTC by adding a positive or negative time after the time - like this:
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 using 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 section (this 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 a schema:
The element in the document should look like this:
The example above represents a period of 5 years.
or like this:
The example above represents a period of 5 years, 2 months, and 10 days.
or like this:
The example above represents a period of 5 years, 2 months, 10 days, and 15 hours.
or like this:
The example above represents a period of 15 hours.
Negative Duration
To specify a negative duration, enter a minus sign before the P:
The example above represents a period of negative 10 days.
Date and Time Data Types
| Name | Description |
|---|---|
| date | Defines a date value |
| dateTime | Defines a date and time value |
| duration | Defines a time interval |
| gDay | Defines a part of a date - day (DD) |
| gMonth | Defines a part of a date - month (MM) |
| gMonthDay | Defines a part of a date - month and day (MM-DD) |
| gYear | Defines a part of a date - year (YYYY) |
| gYearMonth | Defines a part of a date - year and month (YYYY-MM) |
| time | Defines a time value |
Restrictions on Date Data Types
Restrictions that can be used with the date data type:
- enumeration
- maxExclusive
- maxInclusive
- minExclusive
- minInclusive
- pattern
- whiteSpace