What is Date and Time data type in XQuery

In this article we are going to explain Date and Time data type.
  • 2092

Date and Time data type is used to contain date and time. Date and Time data type are four types.

  • Date data type

    The xs:date data type consists of year, month and day; means it specify a date. The date data type represent date in "YYYY-MM-DD" format. Date data type smallest value is 0001-01-01Z and largest value is 9999-12-31Z.

Date has the following constraining facets-

  • pattern
  • enumeration
  • whiteSpace
  • maxInclusive
  • maxExclusive
  • minInclusive
  • minExclusive

Example of Date data type

<xs:element name="Dates" type="xs:date"/>

<Dates>1994-1-1</Dates>

<Dates>1995-5-23</Dates>

  • Time data type

           The time data type represents an instant of time that recurs every day and his smallest value is 00:00:00Z and largest value is 23:59:59Z. The time data type is specified "hh:mm:ss" that format.

Date has also the following constraining facets-

  • pattern
  • enumeration
  • whiteSpace
  • maxInclusive
  • maxExclusive
  • minInclusive
  • minExclusive

Example of Time data type

<xs:element name="StartTime" type="xs:time"/>

<StartTime>10:10:11</StartTime>

<StartTime>11:34:43</StartTime>

  • DateTime data type

              The dateTime data type is used to specify an instant that has the following properties: year, month, day, hour, minute and sec, and his smallest value is 0001-01-01T00:00:00.000000Z and largest value is 9999-12-31T23:59:59.999999Z.

DateTime has  the following constraining facets-

  • pattern
  • enumeration
  • whiteSpace
  • maxInclusive
  • maxExclusive
  • minInclusive
  • minExclusive

Example of Date Time data type

<xs:element name="TimeStart" type="xs:dateTime"/>

<TimeStart>1999-12-23T08:12:23</TimeStart

  • Duration data type

            The duration data type represents a duration of time. Duration data type smallest value is 0001-01-01T00:00:00.000000Z and largest value is 9999-12-31T23:59:59.999999Z.

DateTime has  the following constraining facets-

  • pattern
  • enumeration
  • whiteSpace
  • maxInclusive
  • maxExclusive
  • minInclusive
  • minExclusive

Example of duration data type

<xs:element name="DurationTime" type="xs:duration"/>

<DurationTime>P7Y5M12D</DurationTime

Further Readings

You may also want to read these related articles: here

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.