year

Description

Returns an integer that represents the year in the datepart of a specified date.

Syntax

year(date_expression)

Parameters

date_expression

is an expression of type datetime, smalldatetime, date, time or a character string in a datetime format.

Examples

Example 1

Returns the integer 03:

year("11/02/03")
----------
03
(1 row(s) affected)

Usage

year(date_expression) is equivalent to datepart(yy, date_expression).

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute year.

See also

Datatypes datetime, smalldatetime, date

Functions datepart, day, month