JohneeMac Posted January 11, 2006 Share Posted January 11, 2006 Hi there, i am trying to display some news with the most recent date at the top heres my SQL: $sql = mysql_query("SELECT *, date_format(article_date, '%D %M, %Y') as article_date FROM news_system ORDER BY article_date ASC LIMIT 5"); It seems to mess up and have a random order of things. Thx. Link to comment https://forums.phpfreaks.com/topic/3178-date-problem-order-by/ Share on other sites More sharing options...
LazyJones Posted January 11, 2006 Share Posted January 11, 2006 [!--quoteo(post=335531:date=Jan 11 2006, 10:35 AM:name=JohneeMac)--][div class=\'quotetop\']QUOTE(JohneeMac @ Jan 11 2006, 10:35 AM) 335531[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi there, i am trying to display some news with the most recent date at the top heres my SQL: $sql = mysql_query("SELECT *, date_format(article_date, '%D %M, %Y') as article_date FROM news_system ORDER BY article_date ASC LIMIT 5"); It seems to mess up and have a random order of things. Thx. It most certainly will. The mysql engine sees the dates like this (12.10.2005 -> 12102005, 24.12.1856 -> 24121856) so 24121856 is definetly bigger then 12102005. The date format should be arranged first by year, then by month and then date. Or maybe use TIMESTAMP() instead. Link to comment https://forums.phpfreaks.com/topic/3178-date-problem-order-by/#findComment-10816 Share on other sites More sharing options...
fenway Posted January 11, 2006 Share Posted January 11, 2006 See the reponse to [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=82577\" target=\"_blank\"]this thread[/a] for the answer. Link to comment https://forums.phpfreaks.com/topic/3178-date-problem-order-by/#findComment-10817 Share on other sites More sharing options...
JohneeMac Posted January 11, 2006 Author Share Posted January 11, 2006 Many Thanks. Link to comment https://forums.phpfreaks.com/topic/3178-date-problem-order-by/#findComment-10818 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.