Hi,

Change the alias to date_format(date,'%D %M  %Y') AS
mydate, so you are sure that you sort by the date
field not my the formatted date. Be aware that if you
sort my the formatted string, MySql is going to treat
it as a string and therefore sort it as a string.

"11th July 2002" < "2st July 2002" if we compare them
as strings but 07-11-2002 > 07-02-2002 if we compare
them as dates.

Bye and Good Luck!
--- julian haffegee <[EMAIL PROTECTED]> wrote:
> This must be a regularly appearing problem, which is
> why i'm surprised I
> can't find a webpage on it..
> 
> I have
> 
>   $result = mysql_query("SELECT title, url,
> description, author,
> date_format(date,'%D %M  %Y') AS date FROM
> documents_tbl, url_tbl WHERE
> documents_tbl.title_id = url_tbl.url_id ORDER BY
> date DESC");
> 
> Everything works fine, but the ORDER BY bit sorts
> all dates as 9th, 8th 7th
> etc rather than 31st, 30th and so on.
> 
> can anyone tell me where to look to read all about
> it.
> 
> Thanks Jules
> 
> 
>
---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list
> archive)
> 
> To request this thread, e-mail
> <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try:
> http://lists.mysql.com/php/unsubscribe.php
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to