Reputation: 2150
I try this but it's not working
{
'conditions' => array('Graph.hid' => $hid, 'DATE(Graph.created) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)', 'Graph.number'=>2)
}
Actually needed the current time data of previous day. Can anyone help me? thanks in advance.
Upvotes: 0
Views: 701
Reputation: 142
you can use BETWEEN in your query (find) like this if you have DATETIME :
$yesterday = date("Y-m-d", (time()-86400));
$query = 'SELECT * FROM table WHERE registration between '."'$yesterday 00:00:00'".' and '. "'$yesterday 23:59:59'";
between in cake is :
array('Post.read_count BETWEEN ? AND ?' => array(1,10))
other ways to calculate the last day :
date("Y-m-d", time() - 86400);
date("Y-m-d", strtotime("yesterday"));
date("Y-m-d", strtotime("-1 day"));
Upvotes: 1