THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL YEAR() Function

❮ MySQL Functions

Example

Return the year part of a date:

SELECT YEAR("2017-06-15");
Try it Yourself »

Definition and Usage

The YEAR() function returns the year part for a given date (a number from 1000 to 9999).

Syntax

YEAR(date)

Parameter Values

Parameter Description
date Required.  The date/datetime to extract the year from

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Return the year part of a date:

SELECT YEAR("2017-06-15 09:34:21");
Try it Yourself »

Example

Return the year part of the current system date:

SELECT YEAR(CURDATE());
Try it Yourself »

❮ MySQL Functions