Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter active record compare a date

Tags:

codeigniter

I have a column in a db with a date stored as mm/dd/yyyy. I need to grab all the rows with dates greater than a certain date. (Ex. any date after 01/01/2013). How do I do this using active record?

I have tried

$this->db->select('DATE_FORMAT(date, '%mm/%dd/%Y') as mydate');
$this->db->where('mydate >','01/01/2013');
like image 887
Staysee Avatar asked Dec 27 '22 00:12

Staysee


1 Answers

$this->db->select("DATE_FORMAT(date, '%m/%d/%Y') as mydate",FALSE);
$this->db->from('table');
$this->db->where("DATE_FORMAT(date,'%Y-%m-%d') > '2013-01-01'",NULL,FALSE);
like image 199
csotelo Avatar answered Feb 22 '23 23:02

csotelo