我有一个查询,其中的日期是在&YYYY-MM-DD'格式,我希望对此进行排序。所以,我用了
SELECT DATE_FORMAT(AudiEvent.EventDate,'%d-%m-20%y') as Event_Date
from AudiEvent
ORDER BY Event_Date
实际输出 -
Event_Date
06-12-2013
09-11-2013
18-12-2013
26-11-2013
预期产出 -
Event_Date
09-11-2013
26-11-2013
06-12-2013
18-12-2013
答案 0 :(得分:3)
请在排序
中使用AudiEvent.EventDate
日期字段
SELECT DATE_FORMAT(AudiEvent.EventDate,'%d-%m-20%y') as Event_Date
from AudiEvent
ORDER BY AudiEvent.EventDate
答案 1 :(得分:2)
ORDER BY DATE_FORMAT(AudiEvent.EventDate,'%d-%m-20%y')
答案 2 :(得分:2)
您需要在EventDate
之前添加AudiEvent
SELECT DATE_FORMAT(AudiEvent.EventDate,'%d-%m-20%y') as Event_Date
from AudiEvent
ORDER BY AudiEvent.EventDate
答案 3 :(得分:0)
试试这个,
select DATE_FORMAT(AudiEvent.EventDate,'%d-%m-20%y') as Event_Date
from AudiEvent
order by DATE_FORMAT(AudiEvent.EventDate,'%d-%m-20%y')
答案 4 :(得分:0)
SELECT DATE_FORMAT(AudiEvent.EventDate,'%d-%m-20%y') as Event_Date
from AudiEvent
ORDER BY AudiEvent.EventDate ASC