Surendra Sharma

Surendra Sharma

Search This Blog

Friday, July 19, 2013

How to get 3 character or MMM format month name in sql server

Here is query for showing complete month name, month number and month name in MMM or 3 character format

SELECT
DATENAME(mm,GETDATE()) AS [Month Name],   -- Dispaly complete Month Name
MONTH(GETDATE()) AS [Month Number], -- Dispaly Month number as NN digit
SUBSTRING(DATENAME(mm,GETDATE()),1,3) AS Month Name In MMM  -- Dispaly Month name in 3 characters
Output:


Month Name
Month Number
Month Name In MMM
July
7
Jul

2 comments: