I have a start and end date in my database and a date date variable from a form field. Now I'm trying to query all the lines where $ date is = start / end of the date in db, or ANY date between the two.
This is the opposite of what is described in the docs on how daysAsSql works. I canβt figure out how to make it work. The following line does not work as a search condition in the controller:
'? BETWEEN ? AND ?' => array($date, 'Item.date_start', 'Item.date_end'),
Any help is appreciated. It drives me crazy.
Here is the complete query and the corresponding SQL:
$conditions = array( 'conditions' => array( 'and' => array( '? BETWEEN ? AND ?' => array($date, 'Item.date_start', 'Item.date_end'), 'Item.title LIKE' => "%$title%", 'Item.status_id =' => '1' ))); $this->set('items', $this->Item->find('all', $conditions)); WHERE (('2012-10-06' BETWEEN 'Item.date_start' AND 'Item.date_end') AND (`Item`.`title` LIKE '%%') AND (`Item`.`status_id` = 1))
date time cakephp between
Joshua
source share