MySQL YEAR() Function

In MySQL, the YEAR() function extracts the year part of a date and return it as a number.

YEAR() Syntax

Here is the syntax of MySQL YEAR() function:

YEAR(date)

Parameters

date
Required. A date or datetime expression.

Return value

The MySQL YEAR() function extracts the year part of a date and return it as a number. The return value of YEAR() is 0 or a integer number from 1000 to 9999.

If the argument is NULL, the YEAR() function will return NULL.

YEAR() Examples

Here are some examples of the YEAR() function.

SELECT
    YEAR('2022-02-28'),
    YEAR('2022-02-28 10:11:12'),
    YEAR('0000-01-01')\G
         YEAR('2022-02-28'): 2022
YEAR('2022-02-28 10:11:12'): 2022
         YEAR('0000-01-01'): 0