shooff2332 Posted March 14, 2008 Share Posted March 14, 2008 I have a website for a court where people can go online and check when their court appearance is for the date selected. Everything works smooth in that aspect. The problem that I have is that if the person has a appearance time of 1200pm or 1230pm it displays at the bottom of the page as the last time, where it should be displayed in order of time i.e. 10am,11am,12pm,1pm where currently it displays 3pm,4pm,5pm,12pm,1230pm. I have the data sorted in descending order from the morning to the afternoon when they select the date they are trying to display. Just wondering if there is a time function I am supposed to use or something I am supposed to change in the .ini file. I can post a link to the website if that helps. Thanks for any and all help. Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/ Share on other sites More sharing options...
soycharliente Posted March 14, 2008 Share Posted March 14, 2008 What is the data type for that field? Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/#findComment-492275 Share on other sites More sharing options...
shooff2332 Posted March 14, 2008 Author Share Posted March 14, 2008 The time field is (int) and the am/pm field is (char). Both are in an mysql db which the data is imported to from a txt file which we get from an as/400. Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/#findComment-492283 Share on other sites More sharing options...
soycharliente Posted March 14, 2008 Share Posted March 14, 2008 It sounds like that's your problem. It's sorting smallest to largest according to the properties of integers. 5 is smaller than 12 and all your doing it adding the am/pm to the end. Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/#findComment-492288 Share on other sites More sharing options...
shooff2332 Posted March 14, 2008 Author Share Posted March 14, 2008 That makes sense, other then 12pm is the only number it does that with. It will display 9am,10am,11am before 1pm and so on. But it always displays 12pm at the very end. Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/#findComment-492303 Share on other sites More sharing options...
soycharliente Posted March 14, 2008 Share Posted March 14, 2008 Why aren't you using the TIME/DATETIME data type? It would be MUCH easier. Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/#findComment-492306 Share on other sites More sharing options...
shooff2332 Posted March 14, 2008 Author Share Posted March 14, 2008 I will try that, its just more leg work on the 400 side. But do you have any idea why it displays like that? Thanks for your help by the way. Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/#findComment-492355 Share on other sites More sharing options...
laffin Posted March 14, 2008 Share Posted March 14, 2008 since int and char are seperated, i wud guess it wud be yer merging or sorting algorithm i wud either make it 24 hr designation (am/pm extracted from the time instead) this cud save a lot of time than switching everything over to timestamps but timestamps wud provide better flexibility when doing sql searches Quote Link to comment https://forums.phpfreaks.com/topic/96169-time-of-day-sorting-problem-please-help/#findComment-492391 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.