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 |
|
WoodHouse
Posting Yak Master
211 Posts |
Posted - 2009-08-04 : 05:03:11
|
Hi GuysI have table data like this..Apr06Apr07Apr08Apr09Aug06Aug07Aug08Dec06Dec07Dec08Feb06Feb07Feb08Feb09Jan06Jan07Jan08Jan09Jul06Jul07Jul08Jun06 So i want to order of the months like this...Jan06Jan07Jan08Jan09Feb06Feb07Feb08Feb09Apr06Apr07Apr08Apr09Jul06Jul07Jul08Jun06Aug06Aug07Aug08 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-04 : 05:16:49
|
| order by cast('2000'+col as datetime)MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-04 : 05:17:26
|
| Also use proper datetime datatype to store datesMadhivananFailing to plan is Planning to fail |
 |
|
|
WoodHouse
Posting Yak Master
211 Posts |
Posted - 2009-08-04 : 05:44:37
|
| HiIs it possible to order like this...Jan06Feb06Mar06Jan07Feb07Mar07Jan08Feb08Mar08Jan09Feb09Mar09 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-08-04 : 05:49:51
|
you have to convert the string to datetime and then order it KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-08-04 : 05:52:26
|
[code]order by convert(datetime, '01' + datestrcol)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-04 : 05:59:35
|
quote: Originally posted by WoodHouse HiIs it possible to order like this...Jan06Feb06Mar06Jan07Feb07Mar07Jan08Feb08Mar08Jan09Feb09Mar09
My first reply should be thenorder by cast('01'+col as datetime) MadhivananFailing to plan is Planning to fail |
 |
|
|
WoodHouse
Posting Yak Master
211 Posts |
Posted - 2009-08-04 : 07:21:32
|
| hi KH&MadhivananThanks a Lot |
 |
|
|
|
|
|