In cakephp query conditions, where i have only date which have to meet the conditions with datetime field of table. suppose i have date only(2013-09-21) and field is (2013-09-21 07:45:23). i have get problem to give the condition here.
If @Aryan 's solution doesn't work because you need to convert between formats at the database, then you want to use the MySQL function DATE. This would change the find example to be this:
$row = $this->Model->find('all',
array('fields' => array('........'),
'conditions' => array(
'DATE(Story.created) >' => $date)));
$date_string = "2013-09-21";
$new_date = date('Y-m-d H:i:s', strtotime($date_string));
$row = $this->Model->find('all',
array('fields' => array('........'),
'conditions' => array(
'Story.created >' => $new_date)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With