Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

YEAR

Example

Retrieve the year component from a date.

SELECT YEAR(“2017-06-15”);

Definition and Usage

The YEAR() function returns the numeric year part for a given date, which ranges from 1000 to 9999.

Syntax

YEAR(date)

Parameter Values

Parameter

Description

date

Required: The date or datetime from which to extract the year.

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Retrieve the numeric year component of a date.

SELECT YEAR(“2017-06-15 09:34:21”);

Example

Retrieve the numeric year from the current system date.

SELECT YEAR(CURDATE());