Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

DATE_PART_YEAR Function

The DATE_PART_YEAR function extracts the year from a date.

Syntax

Copy
DATE_PART_YEAR(date)

Argument

date

A date or timestamp column or an expression that implicitly converts to a date or time stamp.

Return Type

INTEGER

Examples

The following example extracts the year from the CALDATE column:

Copy
select caldate, date_part_year(caldate) from date order by dateid limit 10; caldate | date_part_year -----------+---------------- 2008-01-01 | 2008 2008-01-02 | 2008 2008-01-03 | 2008 2008-01-04 | 2008 2008-01-05 | 2008 2008-01-06 | 2008 2008-01-07 | 2008 2008-01-08 | 2008 2008-01-09 | 2008 2008-01-10 | 2008 (10 rows)