sql-date-functions

How can I use SQL's YEAR(), MONTH() and DAY() in Doctrine2?

烂漫一生 提交于 2019-11-27 01:41:59
I want to perform a query which would look like this in native SQL: SELECT AVG(t.column) AS average_value FROM table t WHERE YEAR(t.timestamp) = 2013 AND MONTH(t.timestamp) = 09 AND DAY(t.timestamp) = 16 AND t.somethingelse LIKE 'somethingelse' GROUP BY t.somethingelse; If I am trying to implement this in Doctrine's query builder like this: $qb = $this->getDoctrine()->createQueryBuilder(); $qb->select('e.column AS average_value') ->from('MyBundle:MyEntity', 'e') ->where('YEAR(e.timestamp) = 2013') ->andWhere('MONTH(e.timestamp) = 09') ->andWhere('DAY(e.timestamp) = 16') ->andWhere('u

How can I use SQL's YEAR(), MONTH() and DAY() in Doctrine2?

放肆的年华 提交于 2019-11-26 09:47:11
问题 I want to perform a query which would look like this in native SQL: SELECT AVG(t.column) AS average_value FROM table t WHERE YEAR(t.timestamp) = 2013 AND MONTH(t.timestamp) = 09 AND DAY(t.timestamp) = 16 AND t.somethingelse LIKE \'somethingelse\' GROUP BY t.somethingelse; If I am trying to implement this in Doctrine\'s query builder like this: $qb = $this->getDoctrine()->createQueryBuilder(); $qb->select(\'e.column AS average_value\') ->from(\'MyBundle:MyEntity\', \'e\') ->where(\'YEAR(e