Forum Moderators: coopster

Message Too Old, No Replies

order by date problems date_format

         

helenp

11:22 pm on Sep 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi,
In the select I put an date_format in to display the dates day-month-year, like this:
"SELECT id, DATE_FORMAT(date, '%d-%m-%Y') date FROM bookings order by date");
so fare perfect,

I mean I want to display day-month-year but need to order by year-month-day to make the order correct.

The problem is that when order by date, it is ordered by the day date though itīs first.
Can this be fixed?
The way of displaying the select is:

echo "<tr> \n";
echo "<td>".$row["id"]."</td> \n";
echo "<td>".$row["date"]."</td> \n";
echo "<td>".$row["propiedad"]."</td> \n";
echo "<td>".$row["cliente"]."</td> \n";
echo "<td><a href=edit_reserva2.php?id=".$row["id"]."> Modificar </a></td> \n";
echo "</tr> \n";

Thanks in advance,

ergophobe

11:44 pm on Sep 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



SELECT id, DATE_FORMAT(date, '%d-%m-%Y') as fdate FROM bookings order by date

then further down

echo "<td>".$row["fdate"]."</td> \n";

Tom

helenp

12:04 am on Sep 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hey,
it worked,
Thanks a lot..........