Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date conversaion sorting help

Status
Not open for further replies.

Bell1991

Programmer
Aug 20, 2003
386
US
I have a table that has has a date column but is varchar(20)... This table has 2008/2009 data in in.

How do i sort by date

I have tried:
SELECT convert(varchar,Date,101) FROM autoissuelogdate
order by convert(varchar,Date,101) desc

but that returned 12/31/08 at the top of the list...

Any siggestions (other than changing the column type)?

Thanks in advance and happy new year!
 
You can try...

Code:
order by convert(DateTime,YourDateColumn,101) desc

This code will fail if you have varchar data that cannot be converted to a proper date time.



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top