LD16 LD16 - 5 months ago 26
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

Try:

Order by cast(Field as datetime)
Comments