year-from-dateTime function

The fn:year-from-dateTime function returns the year component of an xs:dateTime value.

Syntax

Read syntax diagramSkip visual syntax diagramfn:year-from-dateTime( dateTime-value)
dateTime-value
The dateTime value from which the year component is to be extracted.

dateTime-value is of type xs:dateTime, or is an empty sequence.

Returned value

If dateTime-value is of type xs:dateTime, the returned value is of type xs:integer. The value is the year component of the dateTime-value, a non-negative value.

If dateTime-value is an empty sequence, the returned value is an empty sequence.

Example

The following function returns the year component of the dateTime value for October 29, 2005 at 8:00 am in the UTC-8 time zone.

fn:year-from-dateTime(xs:dateTime("2005-10-29T08:00:00-08:00"))

The returned value is 2005.