Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get abbreviated Month 1

Status
Not open for further replies.

sconti11

Technical User
Jan 31, 2011
95
US
Below is the code I am currently using:

DATENAME(Month, DATEADD(Month, Month - 1, 0)) AS MonthName

This gives me the Month as January, I need to abbreviate that to just Jan.

Is there a quick way to do this?
 
The abbreviations for all of the months happens to be the first 3 characters of the full month name, so....

[tt][!]Left([/!]DATENAME(Month, DATEADD(Month, Month - 1, 0))[!], 3)[/!] AS MonthName[/tt]

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Simple answer:
Code:
	SELECT LEFT(DATENAME(MONTH, DATEADD(MONTH, Month - 1, 0)), 3) AS MonthName

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
I should modify my answer....

The month abbreviations are the first 3 letters of the full month name for the English language. This is not necessarily true for other languages.

To see a list of abbreviations, you can run this query.

Code:
Select name, alias, months, shortmonths
from   sys.syslanguages



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Awsome!

Kudos to both gmmastros and ousoonerjoe!

 
John (sparkbyte), nice link.

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top