This tutorial explains how to use the MySQL YEAR function with syntax and examples.
The MySQL YEAR function returns the year portion of a date value.
The syntax for the YEAR function in MySQL is:
YEAR( date_value )
A date or datetime value from which to extract the year.
The YEAR function can be used in the following versions of MySQL:
Let's look at some MySQL YEAR function examples and explore how to use the YEAR function in MySQL.
For example:
mysql> SELECT YEAR('2014-01-28');
Output: 2014
mysql> SELECT YEAR('2014-01-28 15:21:05');
Output: 2014
mysql> SELECT YEAR('2013-10-15');
Output: 2013
This last YEAR example would display the year portion of the current system date (current system date is returned by the CURDATE function).
mysql> SELECT YEAR(CURDATE());