![]() |
Unixtime stamp - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Unixtime stamp (/showthread.php?tid=11779) |
Unixtime stamp - El Forum - 09-23-2008 [eluser]Yash[/eluser] Hi, I need to sort unixtimestamp stored in database.I'm just using order_by function for sort i.e. not sufficient. form_unix is helpful...? any help is appreciated. I want to get latest entry only. Unixtime stamp - El Forum - 09-23-2008 [eluser]xwero[/eluser] MAX(datefield) is what you need Unixtime stamp - El Forum - 09-23-2008 [eluser]Yash[/eluser] not working Code: $sql="SELECT * FROM threads WHERE 'dsd_title'=\"".$dddd[$i]['url_title']."\" HAVING max('posted_date')"; Unixtime stamp - El Forum - 09-23-2008 [eluser]xwero[/eluser] What if you do Code: $sql="SELECT * FROM threads WHERE 'dsd_title'=\"".$dddd[$i]['url_title']."\" AND 'posted_date'= max('posted_date')"; Edit : ok above code results in an error which i could have known. But if you first do a query for the highest date and then add that value to the actual query. If you have a database that supports subqueries you can do it in one query. Unixtime stamp - El Forum - 09-23-2008 [eluser]Sumon[/eluser] Would any one of you please explain why the following code will not work whether unixtimestamp data field(posted_date) is integer or long integer. Code: $sql="SELECT * FROM threads WHERE 'dsd_title'=\"".$dddd[$i]['url_title']."\" order by posted_date"; ![]() Unixtime stamp - El Forum - 09-23-2008 [eluser]Yash[/eluser] I want to get latest entry from database.date is factor which decide which entry is latest.It contains now() entry i.e. unix timestamp. Clear? Unixtime stamp - El Forum - 09-23-2008 [eluser]xwero[/eluser] Code: $sql="SELECT * FROM threads WHERE 'dsd_title'=\"".$dddd[$i]['url_title']."\" ORDER BY posted_date DESC limit 1"; Unixtime stamp - El Forum - 09-23-2008 [eluser]Yash[/eluser] Thank you for help final code Code: $this->db->order_by('posted_date','desc'); |