Friday, 22 November 2019

Get Month name from given Date in SQL or DateName function 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:-

Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome.


No comments:

Post a Comment