List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:September 12 2007 8:56pm
Subject:RE: ordering dates
View as plain text  
I suspect that your problem is that you are converting your date field to a
string before sorting. You shouldn't use the same name for the alias as you
do for the field. Try

$result= mysql_query("SELECT date_format(date, '%d/%m/%Y') as
formatted_date, title,
id, display FROM news ORDER BY date DESC ");

Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com


> -----Original Message-----
> From: Ross Hulford [mailto:ross@stripped]
> Sent: Wednesday, September 12, 2007 4:49 PM
> To: mysql@stripped
> Subject: ordering dates
>
> $result= mysql_query("SELECT date_format(date, '%d/%m/%Y') as
> date, title,
> id, display FROM news ORDER BY date DESC ");
>
> I have the query above the problem is oders them like so
>
> 30/05/2007
> 29/07/2007
> 25/0/2007
>
>
> The order is taken by the first number. Is there any way to
> order them
> properly without a timestamp?
>
>
> Ta,
>
> R.
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=1
>
>



Thread
performance of extended insert vs. load dataSid Lane23 Jul
  • Re: performance of extended insert vs. load dataPerrin Harkins23 Jul
  • Re: performance of extended insert vs. load datamos23 Jul
    • Re: performance of extended insert vs. load dataPerrin Harkins23 Jul
  • ordering datesRoss Hulford12 Sep
    • Re: ordering datesMichael Dykman12 Sep
    • Re: ordering datesPhilip Hallstrom12 Sep
    • RE: ordering datesJerry Schwartz12 Sep
Re: performance of extended insert vs. load dataB. Keith Murphy23 Jul
  • Re: performance of extended insert vs. load dataMogens Melander24 Jul
  • Re: performance of extended insert vs. load dataRavi Prasad24 Jul