abrahamgarcia27 Posted April 10, 2013 Share Posted April 10, 2013 (edited) I am trying to sort by date my date posted format is the following 4/9/2013 -> Month / Day / Year I am using the following query (I want to put the newest at top) $mainQuery = "SELECT SQL_CALC_FOUND_ROWS * FROM `".TABLE_BLOG."` ORDER BY DATE(posted_date) DESC LIMIT ".(int)($perPage*($p-1)).','.(int)$perPage." "; But it is not ordering correctly the information Could anyone help me figure this out? Edited April 10, 2013 by abrahamgarcia27 Quote Link to comment Share on other sites More sharing options...
Barand Posted April 10, 2013 Share Posted April 10, 2013 (edited) to sort dates they need to be in a sortable format, which is YYYY-MM-DD Either change your date fields to type DATE and use that format (recommended) or convert the date in the/every query to that format using STR_TO_DATE() function. Edited April 10, 2013 by Barand Quote Link to comment Share on other sites More sharing options...
Solution abrahamgarcia27 Posted April 11, 2013 Author Solution Share Posted April 11, 2013 to sort dates they need to be in a sortable format, which is YYYY-MM-DD Either change your date fields to type DATE and use that format (recommended) or convert the date in the/every query to that format using STR_TO_DATE() function. Thanks i just changed the date field to DATE. Quote Link to comment 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.