Friday 23 February 2018

How we can get complete MONTH name from date in SQL

DATENAME function :

It will return a specified part of a given date in string format. here we will get month name from DATENAME function. 

Query as below:

SELECT  DATENAME(month,GETDATE()) as MonthName---Month Name
SELECT  DATENAME(mm,GETDATE()) as MonthName---Month Name
SELECT  DATENAME(m,GETDATE()) as MonthName---Month Name
select left(datename(month,getdate()),3)as MonthName-- Month Name first three Abbreviation
SELECT  DatePart(mm,GETDATE()) as MonthNumber -- Month Number

Output screen shot as below:-


No comments:

Post a Comment