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`,
`Messages`.`Sender`,
`Messages`.`Subject`,
 DATE_FORMAT( `Messages`.`Date`, '%D %M %Y' ) AS Date,
 LEFT(`Messages`.`Text`, 200 ) AS Preview,
`Messages`.`New`,
`Profiles`.`NickName`,
`Profiles`.`RealName`,
`Profiles`.`Status`,
`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
results?

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
correctly.

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

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