Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

What I have tried:

C#
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
Posted
Updated 13-Nov-16 23:58pm

try this

SQL
declare @month int
 set @month = 11 -- November
 Select 'Month Name' = DateName( month , DateAdd( month , @month , 0 ) - 1 )

refer DATENAME (Transact-SQL)[^]
 
Share this answer
 
v2
hope this Query's helps you:
SQL
select DATENAME(MONTH,  getdate() )
select DATENAME(MONTH, DateAdd( month , 11, 0 ) - 1 ) -- 11 as month value
select DATENAME(MONTH,250 )  --- pass values from 1-365 days
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900