cheesycarrion Posted September 12, 2008 Share Posted September 12, 2008 each time a row is updated, the date gets updated, and I want to sort each item by date with most recent at the top. the problem is that they're out of order with the month when there are months with one digit and months with two digits. the same also applies to the day and hour. I know how I would sort this in php, but if I just got all the data and sorted in in php, I wouldn't be able to use the sql limit. for this example, let's say there are 10 items per page. here's what I have now: page 1: 9/9/08 at 17:19 9/4/08 at 1:49 9/12/08 at 16:51 9/11/08 at 1:10 9/11/08 at 1:07 8/31/08 at 23:52 8/24/08 at 19:32 8/20/08 at 23:21 8/19/08 at 21:50 8/12/08 at 15:03 ======= page 2: 8/1/08 at 15:58 8/1/08 at 15:57 7/28/08 at 22:16 here's how I want it: 9/12/08 at 16:51 9/11/08 at 1:10 9/11/08 at 1:07 9/9/08 at 17:19 9/4/08 at 1:49 8/31/08 at 23:52 8/24/08 at 19:32 8/20/08 at 23:21 8/19/08 at 21:50 8/12/08 at 15:03 ======= page 2: 8/1/08 at 15:58 8/1/08 at 15:57 7/28/08 at 22:16 Is there something I can put in my query for this or should I just get all the items without a limit and sort in php? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 13, 2008 Share Posted September 13, 2008 Your first step in solving this is to use a mysql DATE or DATETIME data type. The format you are using is not directly sortable. 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.