simpjd Posted March 24, 2009 Share Posted March 24, 2009 In my sql database I have a list of dates stored as DD/MM/YY, I need a select statement that will order by date but this dosent work: "SELECT * FROM table ORDER BY date DESC" It orders them like this: 01/02/09 02/01/09 03/06/08 Please Help! Quote Link to comment https://forums.phpfreaks.com/topic/150871-mysql-orderby-date-uk-help/ Share on other sites More sharing options...
simpjd Posted March 24, 2009 Author Share Posted March 24, 2009 P.S. Server version: 5.0.67-0ubuntu6 Quote Link to comment https://forums.phpfreaks.com/topic/150871-mysql-orderby-date-uk-help/#findComment-792545 Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2009 Share Posted March 24, 2009 That date format is not directly sortable because the yyyy mm dd fields are not arranged most significant (year) to least significant (day), which is why the DATE data type exists with a format of yyyy-mm-dd. You should be using a DATE data type to hold dates in a database. Quote Link to comment https://forums.phpfreaks.com/topic/150871-mysql-orderby-date-uk-help/#findComment-792584 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.