Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

DATE_PART_YEAR function

Focus mode
DATE_PART_YEAR function - Amazon Redshift

The DATE_PART_YEAR function extracts the year from a date.

Syntax

DATE_PART_YEAR(date)

Argument

date

A column of data type DATE or an expression that implicitly evaluates to a DATE type.

Return type

INTEGER

Examples

The following example finds the year from a date literal.

SELECT DATE_PART_YEAR(date '20220502 04:05:06.789'); date_part_year --------------- 2022

The following example extracts the year from the CALDATE column. The values in the CALDATE column are dates. For more information about the data used in this example, see Sample database.

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)

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.