xs:dateTime

The primitive type xs:dateTime represents a combined date and time. The lexical representation of xs:dateTime is YYYY-MM-DDThh:mm:ss.sss, which is a concatenation of the xs:date and xs:time representation, with an uppercase letter T between them. The constraints described for the xs:date and xs:time types are also true for xs:dateTime. A time zone can be added to the end, as described in "Time Zones" in Chapter 19.

Table B-4 lists some values of the xs:dateTime type. For more information on working with dates and times, see Chapter 19.

Table B-4. Values of the xs:dateTime type

Values

Explanation

Valid

 
2006-05-03T13:20:00

1:20 P.M. on May 3, 2006

2006-05-03T13:20:15.5

1:20 P.M. and 15.5 seconds on May 3, 2006

2006-05-03T13:20:00-05:00

1:20 P.M. on May 3, 2006, U.S. Eastern Standard Time

2006-05-03T13:20:00Z

1:20 P.M. on May 3, 2006, Coordinated Universal Time (UTC)

2006-05-03T24:00:00

Midnight the evening of May 3/morning of May 4

2006-05-04T00:00:00

Midnight the evening of May 3/morning of May 4 (equal to the previous example)

Invalid

 
2006-05-03T13:00

Seconds must be specified

2006-05-03

The time is required

2006-05-0313:20:00

The letter T is required

 

An empty value or zero-length string is not permitted

Values of type xs:dateTime can be constructed using the standard xs:dateTime constructor. In addition, a function named dateTime can be used to construct an xs:dateTime value from an xs:date and an xs:time. You can obtain the current date/time using the current-dateTime function, which returns a value of type xs:dateTime.

It is possible to cast some values to and from xs:dateTime, as shown in the examples in Table B-5. You can split an xs:dateTime value into its date and time components by casting it to xs:date or xs:time. Additionally, xs:date values can be cast to xs:dateTime, in which case the time components are filled in with zeros. Time zones are unchanged by the cast.

Table B-5. Examples of casting to date and time values

Expression

Result

xs:dateTime("2006-05-03T10:32:15") cast as xs:date
2006-05-03
xs:dateTime("2006-05-03T10:32:15") cast as xs:time
10:32:15
xs:date("2006-05-03") cast as xs:dateTime
2006-05-03T00:00:00
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.176.5