Welcome  |  Sign In     | 
MSDN
     
Transact-SQL Reference
YEAR
Transact-SQL Reference
YEAR

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

Syntax

YEAR ( date )

Arguments

date

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


©2007 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
 
Page view tracker