LD16 LD16 - 1 year ago 152
SQL Question

SQL Server -Order BY

I have a field in table that is varchar(12), however data in that field is a date - 1/1/2016 (I have about 5,000 dates). I've been trying to do an ORDER BY but it doesn't seem to order by the date. How would I go about doing ORDER BY on that field if it's not a DateTIME field??

Answer Source


Order by cast(Field as datetime)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download