Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize
5 out of 8 rated this helpful - Rate this topic

YEAR

SQL Server 2000

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.