YEAR (Transact-SQL)
Returns an integer that represents the year part of a specified date.
Transact-SQL Syntax Conventions
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
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
See Also
Reference
Date and Time Functions (Transact-SQL)