Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-01-13 : 19:51:49
|
| Hi All,I have a field showing month like 1,2,3how i can show January for 1, February for 2 etc..Thanksmk_garg |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-01-13 : 19:54:11
|
| [code]SELECT MonthName = CASE WHEN MonthColumn = 1 THEN 'January' WHEN MonthColumn = 2 THEN 'February' etc... END[/code]You'll probably want to put this into a UDF, so that it can be used in a SELECT in multiple queries.Tara |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-01-13 : 19:55:31
|
| Thanks for your help.I am using Sql server 7.0.mk_garg |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-01-13 : 20:21:54
|
Declare @myMonth intSet @myMonth = 3Select datename(month,convert(varchar,@myMonth)+'/1/2000')Corey |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-01-13 : 20:24:19
|
| Ahhhh yes. Make it a valid date, then get the month name. Never thought of doing it like that.Tara |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-01-13 : 22:16:59
|
| Thanks Coreymk_garg |
 |
|
|
VIG
Yak Posting Veteran
86 Posts |
Posted - 2005-01-14 : 12:05:43
|
| declare @m intset @m=2select datename(mm,dateadd(mm,@m-1,0)) MonthName |
 |
|
|
|
|
|