Help with date sorting

Hi !

I have a database of about 100000 schedules etc. There are 2 columns for date and time. Date column’s format is Y-m-d, while the time is stored like: hh:ii am OR hh:ii pm

Please guide me how i can sort on the DATE column DESC and time column on ASC ? I tried

select … ORDER BY dated DESC, time ASC but it does not seem to be working.

I am sure this must be the formatting issue.

Please help .

ZH

What field type is the time field?

its VarChar

change it to TIME datatype and your sorting issues can then be resolved

Okay, the column is now data type TIME, but still if Order By time ASC, its showing 02:00:00 before 11:00:00 now, you can see that 11AM comes first and 2PM comes later. Does it mean that now I have to change all my stored time to 24 hours time format ?

okay thanks a lot for the guidance you ppl provided. I have just fixed my issue by making my time column a “TIME” type, and then converting all my time to 24 hours time format.