jcstanley Posted October 22, 2006 Share Posted October 22, 2006 HiI 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 ideasThanks Link to comment https://forums.phpfreaks.com/topic/24746-order-by-date-after-formatting/ Share on other sites More sharing options...
sasa Posted October 22, 2006 Share Posted October 22, 2006 try[code]$query = "SELECT itemid, title, picture, DATE_FORMAT(date, '%d %M %y') AS date_f FROM news ORDER BY 'date' desc";[/code] Link to comment https://forums.phpfreaks.com/topic/24746-order-by-date-after-formatting/#findComment-112683 Share on other sites More sharing options...
jcstanley Posted October 22, 2006 Author Share Posted October 22, 2006 It doesn't appear to work :(i get: Warning: mysql_result(): date not found in MySQL result index 2and no are dates displayed. Link to comment https://forums.phpfreaks.com/topic/24746-order-by-date-after-formatting/#findComment-112685 Share on other sites More sharing options...
sasa Posted October 24, 2006 Share Posted October 24, 2006 OKyour output new has index date_f (mean date formated) Link to comment https://forums.phpfreaks.com/topic/24746-order-by-date-after-formatting/#findComment-113488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.