YEAR (T-SQL)

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

Syntax

YEAR(date)

Arguments
date
Is an expression of type datetime or smalldatetime.
Return Types

int

Remarks

This function is equivalent to DATEPART(yy, date).

Examples

This example returns the number of the year from the date 03/12/1998.

SELECT "Year Number" = YEAR('03/12/1998')

GO

  

Here is the result set:

Year Number
------------
1998           

This example specifies the date as a number. Notice that Microsoft® SQL Server™ database interprets 0 as January 1, 1900.

SELECT MONTH(0), DAY(0), YEAR(0)

  

Here is the result set:

----- ------ ------

1     1      1900

See Also

Date and Time Functions


(c) 1988-98 Microsoft Corporation. All Rights Reserved.