Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TSQL: Function to display month in words not numbers

Tags:

tsql

MONTH(CMS.App_Received_Date) as 'App Month'

will return 4 for April when date is like 2012-04-01

will return 5 for May when date is like 2012-05-02 etc

Is there a TSQL function to return April, May, June instead?

i.e. MONTHNAME(CMS.App_Received_Date) as 'App Month'

like image 908
VISQL Avatar asked Feb 21 '23 08:02

VISQL


2 Answers

DATENAME(month, CMS.App_Received_Date) as 'App Month'
like image 100
Kyra Avatar answered Mar 16 '23 01:03

Kyra


SELECT  DATENAME(month, '2012-04-01') AS 'App Month'

Returns a character string that represents the specified datepart of the specified date.

Note that the return value depends on the language environment, in my case it returns Januar (german).

http://msdn.microsoft.com/en-us/library/ms174395.aspx

like image 27
Tim Schmelter Avatar answered Mar 16 '23 02:03

Tim Schmelter