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 |
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2010-04-21 : 06:22:14
|
| Hi All, I have a table with two columns, one column with month and 2 column with some other details MOnth column have only values from 1 to 12. i need a function to display the corresponding monthname according to the value in Month column, like for 1 it should be january, for 2 it should be feb like that.Can anyone help me.....Regards,Divya |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-21 : 06:28:09
|
yup. just do likeSELECT [month] AS MnthNo,DATENAME(mm,DATEADD(mm,[month]-1,0)) AS MnthName FROM YourTable ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-21 : 06:28:43
|
selectcase [month]when 1 then 'jan'when 2 then 'feb'...when 12 then 'dec'end as [month],other columns...from tablewhere ... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-21 : 06:30:47
|
quote: Originally posted by visakh16 yup. just do likeSELECT [month] AS MnthNo,DATENAME(mm,DATEADD(mm,[month]-1,0)) AS MnthName FROM YourTable ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Ok, that's more elegant  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-21 : 06:31:15
|
thanks ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2010-04-21 : 06:37:25
|
quote: Originally posted by visakh16 thanks ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
wow really helpfull codeRegards,Divya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-21 : 06:40:21
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|