How to get the month value/month part from the given Date?

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

There are three methods to get the Month part from given date:
DECLARE @GivenDate datetime
SET @GivenDate='2010-02-22 23:06:38.300'
(1) MONTH(GETDATE()) OutPut: 2
(2) SUBSTRING(CONVERT(varchar(30),GETDATE(),107),1,3) Output: Feb
(3) DatePart(M,GETDATE()) output: 2

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response