Reputation: 1091
I just want to pull only date from a datetime column in zend framework 2. I have written this as follows -
$select->where->between('date(view_logs.date)', '2013-01-01', '2013-03-31');
to get the following result in query.
WHERE DATE(`view_logs`.`date`) BETWEEN '2013-01-01' AND '2013-03-31'
But this is not working. Parenthesis and casting is not generated. Can anyone help me to write date casting in zend framework 2?
Upvotes: 0
Views: 2213
Reputation: 12809
I think you will need to use an expression there
$select->where->addPredicate(
new \Zend\Db\Sql\Predicate\Expression("date(view_logs.date) BETWEEN '2013-01-01' AND '2013-03-31'")
);
what error are you getting?
Upvotes: 2