Convert Month Number to Month Name Function in SQL
Posted By: Saif Khan
I have months stored in SQL Server as 1,2,3,4,…12. I would like to display them as January,February etc. Is there a function in SQL Server like MonthName(1) = January? I am trying to avoid a CASE statement, if possible.
Solution
A little hacky but should work:
SELECT DATENAME(month, DATEADD(month, @mydate-1, CAST('2008-01-01' AS datetime)))
Answered By: Alexander Kojevnikov
Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.