Name

YEAR()

Synopsis

YEAR(date)

This function returns the year of the date provided. It returns values from 1,000 to 9,999, and returns 0 for a zero date. Here is an example:

SELECT YEAR('2008-01-01')
AS 'Year';

+------+
| Year |
+------+
| 2008 |
+------+

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.