YEAR_ISO scalar function

Returns the year of ADATE, unless the ISO week of ADATE exists in the prior year in which case that year is returned.

Prototypes

YEAR_ISO(ADATE DATE)
YEAR_ISO(ADATE TIMESTAMP)
YEAR_ISO(ADATE VARCHAR(26))

RETURNS SMALLINT

Description

Returns the year of ADATE, unless the ISO week number (see the built-in function WEEK_ISO) of ADATE belongs to the prior year, in which case the prior year is returned.

Parameters

ADATE
The date to calculate the ISO-week based year number for.

Examples

Calculate the ISO-week based year number of the 1st of January, 2010:

VALUES YEAR_ISO(DATE(2010, 1, 1));
1
------
  2009

Calculate the ISO-week based year number of the 4th of January, 2010 (dates beyond the 4th of January will always be in the year of the date given the definition of ISO weeks):

VALUES YEAR_ISO(DATE(2010, 1, 4)));
1
------
  2010

See Also