SQL Server Articles

Submit Article
Home » Articles » SQL Server » Date Time FunctionsRSS Feeds

YEAR Function

Posted By: Sarita Patel     Category: SQL Server     Views: 2192

This article explains the use of a YEAR function in sql server with examples.

YEAR function is used to get year part from the specified date.

Syntax of YEAR Function :


date is an expression of datetime or smalldatetime type.
It returns an integer value.

Examples of YEAR Function :

Example 1 : Use of YEAR function in select clause

SELECT YEAR('05/31/2000')  


Above example returns year of specified date in  a string format.

Example 2 : Use of YEAR function in where clause

SELECT ShipName, OrderDate
FROM   Orders
WHERE YEAR('05/31/1998') = YEAR(OrderDate)  

ShipName                        OrderDate
Lehmanns Marktstand      1998-01-30 00:00:00.000
HILARION-Abastos          1998-02-02 00:00:00.000 

Above example displays all orders having year 1998.  


Didn't find what you were looking for? Find more on YEAR Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of YEAR Function is from United States.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!