List:General Discussion« Previous MessageNext Message »
From:mikesz Date:February 8 2008 8:23am
Subject:Date sorting problem with Date_Format?
View as plain text  
Hello mysql,

I have a PHP script that is running the following query:

SELECT `Messages`.`ID`,
 DATE_FORMAT( `Messages`.`Date`, '%D %M %Y' ) AS Date,
 LEFT(`Messages`.`Text`, 200 ) AS Preview,
`Profiles`.`ID` as pID
 FROM `Messages`
 LEFT JOIN Profiles ON Messages.Sender = Profiles.ID 
WHERE Recipient = "5" ORDER BY `Date` DESC;

The problem is that the ORDER BY `Date` DESC is generating random

If I run this same script interactively in an sql window it works correctly.

If I remove DATE_FORMAT function and just call `Date`, the script sorts and displays

Is this a bug?
Best regards,
 mikesz                          mailto:mikesz@stripped

Date sorting problem with Date_Format?mikesz8 Feb
  • Re: Date sorting problem with Date_Format?mikesz8 Feb