title: How can I use SQL's YEAR(), MONTH() and DAY() in Doctrine2?
body: <p>I want to perform a query which would look like this in native SQL:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>If I am trying to implement this in Doctrine's query builder like this:</p>
  
  <pre><code>$qb = $this-&gt;getDoctrine()-&gt;createQueryBuilder();
  $qb-&gt;select('e.column AS average_value')
     -&gt;from('MyBundle:MyEntity', 'e')
     -&gt;where('YEAR(e.timestamp) = 2013')
     -&gt;andWhere('MONTH(e.timestamp) = 09')
     -&gt;andWhere('DAY(e.timestamp) = 16')
     -&gt;andWhere('u.somethingelse LIKE somethingelse')
     -&gt;groupBy('somethingelse');
  </code></pre>
  
  <p>I get the error exception</p>
  
  <blockquote>
    <p>[Syntax Error] line 0, col 63: Error: Expected known function, got 'YEAR'</p>
  </blockquote>
  
  <p>How can I implement my query with Doctrines query builder?</p>
  
  <p><strong>Notes:</strong></p>
  
  <ul>
  <li>I know about <a href="http://docs.doctrine-project.org/en/latest/reference/native-sql.html">Doctrine's Native SQL</a>. I've tried this, but it leads to the problem that my productive and my development database tables have different names. I want to work database agnostic, so this is no option.</li>
  <li>Although I want to work db agnostic: FYI, I am using MySQL.</li>
  <li>There is way to extend Doctrine to "learn" the <code>YEAR()</code> etc. statements, e.g. as <a href="http://www.simukti.net/blog/2012/04/05/how-to-select-year-month-day-in-doctrine2/">seen here</a>. But I am looking for a way to avoid including third party plugins.</li>
  </ul>