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 ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access