MariaDB YEAR() Function

In MariaDB, YEAR() is a built-in function that returns the year from a given date expression.

MariaDB YEAR() Syntax

This is the syntax of the MariaDB YEAR() function:

YEAR(date)

Parameters

date

Required. A date or datetime expression.

Return value

The MariaDB YEAR() function extracts and returns the year part of a date. The return value of the YEAR() function is 0 or a number between 1000 and 9999.

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

MariaDB YEAR() Examples

Here are some common examples of the Mariadb YEAR() function.

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

Output:

         YEAR('2022-02-28'): 2022
YEAR('2022-02-28 10:11:12'): 2022
         YEAR('0000-01-01'): 0

Conclusion

In MariaDB, YEAR() is a built-in function that returns the year from a given date expression.