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 numerical year component from a date.

SELECT YEAR(‘2017/08/25’AS Year;

Definition and Usage

The YEAR() function retrieves the numeric representation of the year from a given date.

Syntax

YEAR(date)

Parameter Values

Parameter

Description

date

Mandatory. The date or datetime value from which the year is to be extracted.

Technical Details

Return type:

int

Works in:

 SQL Server (from 2008 onward), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse

More Examples

Example

Retrieve the numeric year component from a date.

SELECT YEAR(‘1998/05/25 09:08’AS Year;