xs:dayTimeDuration

The xs:dayTimeDuration type is a restriction of the xs:duration type, with only day (D), hour (H), minute (M), and second (S) components allowed. Its lexical representation is PnDTnHnMnS, where an uppercase P starts the expression, n indicates the quantity of each component, and an uppercase letter T separates the day and time components. For example, the value P3DT5H represents a period of three days and five hours. You can omit components whose quantity is zero, but at least one component is required.

All of the lexical rules for xs:duration also apply to the xs:dayTimeDuration type. This includes allowing a negative sign at the beginning of the value. Table B-6 lists some values of the xs:dayTimeDuration type.

Important

In previous versions of XQuery (including the Candidate Recommendation), dayTimeDuration was prefixed with xdt: instead of xs: because it was in a different namespace. Some processors still support the previous namespaces for these types instead.

Unlike the xs:duration type, the xs:dayTimeDuration type is totally ordered, meaning that its values can be compared using the operators <, >, <=, and >=. For more on working with durations, see Chapter 19.

Table B-6. Values of the xs:dayTimeDuration type

Values

Explanation

Valid

 
P6DT11H32M20S

6 days, 11 hours, 32 minutes, 20 seconds

P2DT3H

2 day, 3 hours

PT40H

40 hours (the number of hours can be more than 24)

PT0S

0 seconds

-P60D

Minus 60 days

Invalid

 
P2Y

Years and months may not be specified

P15.5D

Only the seconds number can contain a decimal point

P1D2H

The letter T must be used to separate day and time components

PT30S35M

Minutes must appear before seconds

 

An empty value or zero-length string is not permitted

..................Content has been hidden....................

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