Order By Time Not Working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Order By Time Not Working (/showthread.php?tid=70051) |
Order By Time Not Working - wolfgang1983 - 02-13-2018 Hi, I am working on my project but for some reason my order_by('time', 'asc') is not sorting out my list correct As you can see number 4 and 8 should be closer together but is not I am not sure if its because the way I have my database column set up if it is please let me know what it should be. How can I make sure is displayed by correct time or career? PHP Code: public function list() { Here is a copy of my database RE: Order By Time Not Working - InsiteFX - 02-13-2018 Look at this maybe it will help you. MySQL EXTRACT() Function You can use this with order by also... RE: Order By Time Not Working - wolfgang1983 - 02-13-2018 (02-13-2018, 04:26 AM)InsiteFX Wrote: Look at this maybe it will help you. Thanks I changed couple things in data base I had it like int() in column changed column to text now time in correct order RE: Order By Time Not Working - InsiteFX - 02-13-2018 You should use DATETIME DATE and TIME fields for storing date and time. RE: Order By Time Not Working - wolfgang1983 - 02-13-2018 (02-13-2018, 08:15 AM)InsiteFX Wrote: You should use DATETIME DATE and TIME fields for storing date and time. What do you think the career should be for the database column? I changed the time column to TIME how ever it removed 30.29 seconds it removed the .29 now only shows 00:00:30 RE: Order By Time Not Working - InsiteFX - 02-14-2018 Career should be either a varchar(length) or text. For the Time you can use this: MySQL TIME_FORMAT() Function RE: Order By Time Not Working - Agileinfoways - 02-15-2018 Would be problem in field selection, Might be You have choosed VARCHAR Field insted of DATETIME. RE: Order By Time Not Working - InsiteFX - 02-15-2018 If you read the posts you would have read that he changed it to a TIME field. |