Export (0) Print
Expand All
Expand Minimize
9 out of 13 rated this helpful - Rate this topic

YEAR (Transact-SQL)

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

Topic link icon Transact-SQL Syntax Conventions


YEAR ( date )
date

An expression of type datetime or smalldatetime.

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

The following 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            

The following example specifies the date as a number. The Microsoft SQL Server 2005 Database Engine interprets MONTH(0) as 1 (January), DAY(0) as 1, and YEAR(0) as 1900.

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

Here is the result set.

----- ------ ------
1     1      1900
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.