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 |
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2009-05-12 : 05:22:04
|
| HI...I ahve fired a querySelect Month(Getadte())this is returnig the numerical no of month.can some one tell me how i can convert it into Charrecter likeSelect Month(Getdate()) gives 5i want to be as "May"please telll me if any one know....Thanx |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-05-12 : 05:27:45
|
| SELECT datename(month,getdate())MadhivananFailing to plan is Planning to fail |
 |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2009-05-12 : 05:35:51
|
quote: Originally posted by madhivanan SELECT datename(month,getdate())MadhivananFailing to plan is Planning to fail
This Works, Thanks For the quick help... :) |
 |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2009-05-12 : 05:57:23
|
quote: Originally posted by madhivanan SELECT datename(month,getdate())MadhivananFailing to plan is Planning to fail
Madhivaan, i have a colum of datetime type having entries for all months of 2007 in format 'dd-mm-yyyy'and i have fetch all the month of 2007 in the format like 'May or june or ....Datename Function is returning full name of monthto reduce the name of month up to desireable 3 charr. i used Left () functione.g. Left(Datename(month, Columnname)) to get month name's 3initial charracters.But how can i sort the names in order Jan, FEB, MAR, APR...Please look in this matter also.Thanks |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-05-12 : 06:02:29
|
| declare @t table(id int, dateval datetime)insert into @t select 1,'1/1/2009'insert into @t select 2,'3/1/2009'insert into @t select 3,'2/1/2009'insert into @t select 4,'7/1/2009'insert into @t select 5,'5/1/2009'insert into @t select 6,'11/1/2009'select left(datename(month,dateval),3) from @t order by month(dateval) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-12 : 06:54:58
|
quote: Originally posted by arorarahul.0688
quote: Originally posted by madhivanan SELECT datename(month,getdate())MadhivananFailing to plan is Planning to fail
Madhivaan, i have a colum of datetime type having entries for all months of 2007 in format 'dd-mm-yyyy'and i have fetch all the month of 2007 in the format like 'May or june or ....Datename Function is returning full name of monthto reduce the name of month up to desireable 3 charr. i used Left () functione.g. Left(Datename(month, Columnname)) to get month name's 3initial charracters.But how can i sort the names in order Jan, FEB, MAR, APR...Please look in this matter also.Thanks
Your query should be just returning the date to your application and let the front end application display the the month name as JAN, FEB etcor alternatively, you can return 2 column, one is the original date and the other is the month nameselect [date], left(datename(month, [date]), 3)from sometableorder by [date] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2009-05-12 : 07:21:07
|
| Thanks... this logic workd :) thanks for ur time |
 |
|
|
|
|
|
|
|