我在格式的表格中有一堆日期August 31, 2013, 5:02 am
。我需要将这些转换为日期并按日期排序。我正在使用下面的查询,但它以一种奇怪的方式返回日期。
SELECT name, date, link FROM table_name ORDER BY str_to_date(date, '%M %e, %Y, %l %p')
因此,对于一组示例数据,我有:
August 31, 2013, 5:02 am
October 10, 2013, 2:14 pm
October 14, 2013, 7:00 pm
October 22, 2013, 1:46 pm
October 22, 2013, 2:47 pm
但是,当查询运行时,排序发生如下:
August 31, 2013, 5:02 am
October 22, 2013, 2:47 pm
October 22, 2013, 1:46 pm
October 10, 2013, 2:14 pm
October 14, 2013, 7:00 pm
我需要做什么来更正查询并正确显示数据?