I have been trying and trying to properly sort records through a mySQL
query. I have hour, minute and AM/PM values stored separately in a
database as varchars. I'm trying to concat those, cast them to a time
value and sort them. I have found that it sorts some properly but other
it does not.
The following query:
CAST(CONCAT(hour, ':', minute, ' ', ampm) AS TIME) AS myTime
ORDER BY myTime
Sorts some results like this:
10:30 PM
8:30 PM
9:30 PM
But other are perfect:
10:00 AM
11:00 AM
12:00 PM
1:00 PM
2:00 PM
3:00 PM
4:00 PM
5:00 PM
These exact results we part of the same recordset. Can anyone help me
with this? It would be greatly, greatly appreciated.
Thanks in advance!