Reputation: 31
I have a column with datetime data type and I want to build a SQL query in Zend Framework2 which compare date part with user input date.
Need to build similar part as DATE(datetime column) = '2014-09-16' with; $select->where();
would be very grateful if someone could help on this.
Upvotes: 1
Views: 2088
Reputation: 77
Use like this:
$date = '2014.05.24';
$select->where('date(expecting_date) = "'.$date.'"');
Upvotes: 1
Reputation: 58
You should use predicate expression for these kind of conditions, like :
$select = new \Zend\Db\Sql\Select(table name);
$select->where(new \Zend\Db\Sql\Predicate\Expression('DATE(datetime) = ?', '2014-09-16'));
Upvotes: 1