| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Philip Hallstrom | Date: | September 12 2007 9:12pm |
| Subject: | Re: ordering dates | ||
| View as plain text | |||
> $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? You're ordering by "date" but previously you turn "date" into a string by calling date_format on it. Change the "as date" to something else and then the ordering will be chronologically descending. Like this: SELECT date_format(date, '%d/%m/%Y') as formatted_date, title, id, display FROM news ORDER BY date DESC
| Thread | ||
|---|---|---|
| • performance of extended insert vs. load data | Sid Lane | 23 Jul |
| • Re: performance of extended insert vs. load data | Perrin Harkins | 23 Jul |
| • Re: performance of extended insert vs. load data | mos | 23 Jul |
| • Re: performance of extended insert vs. load data | Perrin Harkins | 23 Jul |
| • ordering dates | Ross Hulford | 12 Sep |
| • Re: ordering dates | Michael Dykman | 12 Sep |
| • Re: ordering dates | Philip Hallstrom | 12 Sep |
| • RE: ordering dates | Jerry Schwartz | 12 Sep |
| • Re: performance of extended insert vs. load data | B. Keith Murphy | 23 Jul |
| • Re: performance of extended insert vs. load data | Mogens Melander | 24 Jul |
| • Re: performance of extended insert vs. load data | Ravi Prasad | 24 Jul |
