Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
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());