Im having a problem comparing dates in a database to a week from now using activerecord. I’m trying to return a list of events with their start date less than a week from now.
The event_start_date is in the format of 2011-06-30 09:00:00
$this->db->select('event_id,title,event_start_date,location');
$this->db->where('event_start_date <=',DATE_ADD(NOW(),INTERVAL 7 DAYS ));
$query = $this->db->get('sd_events');
Having trouble working out the right syntax for this, any help would be appreciated 🙂
Two things. First, have you tried putting your where clause in quotes like this:
Second, if necessary just skip using the where function and put the entire query in like this: