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 a
SUBSTRING('JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC ', (@intMonth * 4) - 3, 3)
SELECT DATENAME(MONTH,dateadd(month, -3,getdate()))
Working for me
SELECT MONTHNAME(<fieldname>) AS "Month Name" FROM <tablename> WHERE <condition>
Declare @MonthNumber int
SET @MonthNumber=DatePart(Month,GETDATE())
Select DateName( month , DateAdd( month , @MonthNumber , 0 ) - 1 )
Explaination:
MonthNumber
DatePart
which Return Month NumberThe easiest way is by calling the function MONTHNAME(your_date)
. your_date can be a static value or the value from one of your table fields.
It is very simple.
select DATENAME(month, getdate())
output : January