SQL Server: YEAR Function

YEAR function

This SQL Server tutorial explains how to use the YEAR function in SQL Server (Transact-SQL) with syntax and examples.

Description

In SQL Server (Transact-SQL), the YEAR function returns a four-digit year (as a number) given a date value.

Syntax

The syntax for the YEAR function in SQL Server (Transact-SQL) is:

YEAR( date_value )

Parameters or Arguments

date_valueThe date from which to extract the four-digit year.

Note

Applies To

The YEAR functions can be used in the following versions of SQL Server (Transact-SQL):

  • SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

Example

Let’s look at some SQL Server YEAR functions examples and explore how to use the YEAR functions in SQL Server (Transact-SQL).

For example:

SELECT YEAR('2014/04/28');
Result: 2014

SELECT YEAR('2013/03/31 10:05');
Result: 2013

SELECT YEAR('2015/12/01 10:05:18.621');
Result: 2015

Leave a Reply