What is the best way to get the month name from an int value
within a mssql statement ?
(there is no need to consider the language settings)
e.g.
1 -> January
11 -> Novembre
My first approach seems to work but is very ugly:
CASE WHEN my_month_int<10
THEN DATENAME(month,"20000"+cast(my_month_int as varchar(2))+"15 00:00:00")
ELSE DATENAME(month,"2000"+cast(my_month_int as varchar(2))+"15 00:00:00")
END AS my_month_nameselect datename(m,dateadd(m,my_month_int-1,0)) as my_month_name
:cool:|||Thanx a lot, r937. Nice trick.sql
No comments:
Post a Comment