fn:year-from-date

Returns the year component of an xs:date.

Signature

fn:year-from-date($arg as xs:date?) as xs:integer?

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

If $arg is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an xs:integer representing the year in the local value of $arg. The value may be negative.

Notes

The year returned is the same numeric value that appears in the lexical representation, which for negative years means the meaning may vary depending on whether XSD 1.0 or XSD 1.1 conventions are in use.

Examples

The expression fn:year-from-date(xs:date("1999-05-31")) returns 1999.

The expression fn:year-from-date(xs:date("2000-01-01+05:00")) returns 2000.

The expression fn:year-from-date(xs:date("-0002-06-01")) returns -2. (The result is the same whether XSD 1.0 or 1.1 is in use, despite the absence of a year 0 in the XSD 1.0 value space.)