totn MariaDB Functions

MariaDB: YEAR Function

This MariaDB tutorial explains how to use the MariaDB YEAR function with syntax and examples.

Description

The MariaDB YEAR function returns the year portion of a date value.

Syntax

The syntax for the YEAR function in MariaDB is:

YEAR( date_value )

Parameters or Arguments

date_value
A date or datetime value from which to extract the year.

Note

Applies To

The YEAR function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB YEAR function examples and explore how to use the YEAR function in MariaDB.

For example:

SELECT YEAR('2014-05-19');
Result: 2014

SELECT YEAR('2014-05-19 15:21:05');
Result: 2014

SELECT YEAR('2013-12-24');
Result: 2013

This last YEAR example would display the year portion of the current system date (current system date is returned by the CURDATE function).

SELECT YEAR(CURDATE());