How to get the year part from the given Date?

 Posted by Lakhangarg on 2/22/2010 | Category: Sql Server Interview questions | Views: 2289

There are two methods to get the Year part from given date:
DECLARE @GivenDate datetime
SET @GivenDate='2010-02-22 23:06:38.300'

(1) Year(GETDATE()) Output: 2010
(2) DatePart(yy,GETDATE()) Output: 2010

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response