Jump to content

Archived

This topic is now archived and is closed to further replies.

jcstanley

Order by DATE after Formatting

Recommended Posts

Hi

I had 'order by date' working fine:
$query = "SELECT itemid, title, picture, date FROM news ORDER BY 'date' desc";


but i wanted to change the format of the date was displayed so i changed it to:
$query = "SELECT itemid, title, picture, DATE_FORMAT(date, '%d %M %y') AS date FROM news ORDER BY 'date' desc";

Now the date format is ok but it won't order by the date!

Any ideas

Thanks

Share this post


Link to post
Share on other sites
try[code]$query = "SELECT itemid, title, picture, DATE_FORMAT(date, '%d %M %y') AS date_f FROM news ORDER BY 'date' desc";[/code]

Share this post


Link to post
Share on other sites
It doesn't appear to work  :(

i get: Warning: mysql_result(): date not found in MySQL result index 2

and no are dates displayed.

Share this post


Link to post
Share on other sites
OK
your output new has index date_f (mean date formated)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.