YEAR Function [Date and Time]

Returns a 4-digit number corresponding to the year of the given date/time.

Syntax

YEARdatetime-expression )

Parameters

Parameter

Description

datetime-expression

A date and time.

Returns

SMALLINT

Example

The following statement returns the value 1998:

SELECT YEAR( '1998-07-13 06:07:12' ) FROM iq_dummy

Usage

The YEAR function is the same as the first syntax of the YEARS function.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise.

Related reference
CAST Function [Data Type Conversion]
CONVERT Function [Data Type Conversion]
HOURS Function [Date and Time]
MINUTES Function [Date and Time]
MONTHS Function [Date and Time]
REPLACE Function [String]
SECOND Function [Date and Time]
WEEKS Function [Date and Time]
YEARS Function [Date and Time]
NTILE Function [Analytical]