php - Codeigniter: Order by ascending date
Hi this is my model code for ordering and getting the data:
$this->db->order_by($oBy, "asc"); $query = $this->db->get('books');
Everything is working fine, however in my database i am storing the date as a string, e.g. 01-Jan-2014.
Therefore when i order the date it will order it by the day and not year, may i know how can i solve it by sorting by the year, however the data will still display out as 01-Jan-2014 and also it will be displayed in ascending order? Thank you!
This will solve your problem
I suppose that $oBy is your column name
%d = Day of the month, numeric (00..31)
%b = Abbreviated month name (Jan..Dec)
%Y = Year, numeric, four digits