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 Quote 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] Quote 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. Quote 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) Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.