Friday, 29 July 2011

To display Month name instead of Month number in SQL Server

-- Consider following statement 
SELECT DATENAME(m, str(Month_Number) + '/1/2011')
-- for eg:
SELECT Year, DATENAME(m, Month + '/1/2011') AS Month,from calendar

-- Here m will be the output value
-- str(Month_Number) function convert month number to string i.e 2 => "2"
-- finally whole string "02/1/2011" is passed as argument

0 comments:

Post a Comment