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 |
|
SuperSQLNewb
Starting Member
9 Posts |
Posted - 2009-03-10 : 15:34:17
|
| Hi am trying to order my query by date. The problem though is that my date is formatted like: dd/mm/yySo it gets order like:02/06/0802/11/0902/13/0802/18/09And I want:02/06/0802/13/0802/11/0902/18/09I have tried this: SELECT CONVERT(varchar,ReviewDate,111) AS Date FROM Table ORDER BY CONVERT(varchar,ReviewDate,111)But that does not see to do anything. ReviewDate is VarChar :(Thanks for any help! |
|
|
NeilG
Aged Yak Warrior
530 Posts |
Posted - 2009-03-10 : 15:40:39
|
| Have you also added on ASC to order the dates in ascending order |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-03-10 : 15:41:19
|
| Try converting it to a datetime instead of varchar in your order by. |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-03-10 : 15:45:45
|
| Try this...SELECT ReviewDate FROM Table ORDER BY cast(ReviewDate as datetime) ASC |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-03-10 : 15:46:27
|
| Ohh...dint realize Rick had mentioned it earlier....had the reply window open for sometime i guess. |
 |
|
|
SuperSQLNewb
Starting Member
9 Posts |
Posted - 2009-03-10 : 16:17:57
|
| SELECT ReviewDate FROM Table ORDER BY cast(ReviewDate as datetime) ASCThis worked! Thank you very much! |
 |
|
|
|
|
|