YEAR (Transact-SQL)
SQL Server 2005
Returns an integer that represents the year part of a specified date.
Transact-SQL Syntax Conventions
- date
-
An expression of type datetime or smalldatetime.
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