# xf:get-hours-from-dayTimeDuration

Extracts the number of hours from the hours component of $dayTimeDuration-var.

If the value of $dayTimeDuration-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

### Signatures

xf:get-hours-from-dayTimeDuration(xf:dayTimeDuration? $dayTimeDuration-var) —> xs:integer?

### Arguments

Data Type | Argument | Description
--- | --- | ---
xf:dayTimeDuration? | $dayTimeDuration-var | Contains a representation of a time duration which can contain days, hours, minutes, and seconds.

### Returns

Returns the number as hours as an integer from hours component of $dayTimeDuration-var.

### Examples

#### Get Hours from dayTimeDuration with All Components

    <hours>{xf:get-hours-from-dayTimeDuration(xf:dayTimeDuration("P7DT9H65M20S"))}</hours>

The preceding query generates the following result:

    <hours>9</hours>

Note: Even though 65 minutes is specified in the minutes component (65M) of the dayTimeDuration creation string (adding up to an additional hour), only 9 hours are returned as originally specified by the hours component (9H).

#### Get Hours from dayTimeDuration with Just Negative Hours

    <hours>{xf:get-hours-from-dayTimeDuration(xf:dayTimeDuration("-PT3H"))}</hours>

The preceding query generates the following result:

    <hours>-3</hours>

#### Get Hours from dayTimeDuration with No Hours

    <hours>{xf:get-hours-from-dayTimeDuration(xf:dayTimeDuration("P2DT20S"))}</hours>

The preceding query generates the following result:

    <hours>0</hours>

Related Topics

W3C get-hours-from-dayTimeDuration function description.

W3C dayTimeDuration data type description.