xuma Posted February 8, 2012 Share Posted February 8, 2012 I have a table like below and i need to sort by date field but i cant figure out how.And i cant change database. ID DATE ---------------------------------- 871 27.09.11/09:04 872 29.09.11/14:27 875 24.11.11/16:11 874 21.11.11/15:03 876 26.11.11/14:18 877 26.11.11/14:19 879 11.12.11/14:45 880 14.12.11/14:42 881 14.12.11/14:42 882 21.12.11/09:30 892 23.12.11/15:16 893 23.12.11/15:50 894 29.12.11/13:30 895 02.01.12/16:09 896 02.01.12/16:10 897 03.01.12/10:05 898 03.01.12/10:05 899 03.01.12/13:20 900 04.01.12/14:36 901 06.01.12/13:33 903 09.01.12/13:50 904 09.01.12/14:12 905 09.01.12/14:16 906 15.01.12/21:52 907 15.01.12/21:52 919 29.01.12/17:44 909 17.01.12/13:12 935 04.02.12/19:25 917 29.01.12/17:44 918 29.01.12/17:44 Quote Link to comment Share on other sites More sharing options...
trq Posted February 8, 2012 Share Posted February 8, 2012 They are not proper dates, they must be some form of text field. See http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date Quote Link to comment Share on other sites More sharing options...
xuma Posted February 8, 2012 Author Share Posted February 8, 2012 I dont need min and hour part so can we use together , SUBSTRING() and STR_TO_DATE() function together for proper query. Quote Link to comment Share on other sites More sharing options...
trq Posted February 8, 2012 Share Posted February 8, 2012 Try it and see. Quote Link to comment Share on other sites More sharing options...
fenway Posted February 8, 2012 Share Posted February 8, 2012 Sure, you can fake it -- but it will act faked forever. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 8, 2012 Share Posted February 8, 2012 Why can't you change the database? If you want good results you need a good database. 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.