Can MySQL properly sort DATETIME columns when the values have been formatted with DATE_FORMAT?
Pretty much self-explanatory. Can MySQL sort dates (i.e. not alphabetically but like a date) when the dates have been formatted with DATE_FORMAT
?
Specifically, in my case, only the DATE part has been extracted from the DAT开发者_JAVA百科ETIME values.
Yes.
ORDER BY DATE(`date_time`) DESC
If you have already calculated this when selecting columns, just use its alias.
SELECT DATE(`date_time`) AS `date`
FROM `table`
ORDER BY `date` DESC
精彩评论