title: Symfony2 Catchable Fatal Error: Object of class DateTime could not be converted to string
body: <p>I have a person (Employee) search that is supposed to return a list of people by name, surname, date of birth and some other parameters. the search works fine for every parameter exempt for the date parameters, like date of birth. my controller code is this:</p>
  
  <pre><code>        $aWorker = new Worker();
      $searchWorkerForm = $this-&gt;createFormBuilder($aWorker)
              -&gt;add('omang', 'text', array('required' =&gt; false))
              -&gt;add('workerName', 'text', array('required' =&gt; false))
              -&gt;add('workerSurname', 'text', array('required' =&gt; false))
              -&gt;add('birthDay', 'date', 
                      array('required' =&gt; false, 'years' =&gt; range(1950, 2020)))
              -&gt;add('dateOfEmployment', 'date', array('required' =&gt; false))
              -&gt;add('search', 'submit')
              -&gt;getForm();
      //Handle Request
      if ($request-&gt;getMethod() == 'POST')
          $searchWorkerForm-&gt;handleRequest($request);
  
          $aWorkerList = $this-&gt;getDoctrine()
               -&gt;getRepository('OsdRetireBundle:Worker')
               -&gt;findByPersonDetails($aWorker-&gt;getOmang(),
                       $aWorker-&gt;getWorkerName(),
                       $aWorker-&gt;getWorkerSurname(),
                       $aWorker-&gt;getBirthDay(),
                       $aWorker-&gt;getDateOfEmployment());
  //...
  </code></pre>
  
  <p>The findByPersonDetails function is this:</p>
  
  <pre><code>public function findByPersonDetails($omang, $WorkerName, 
          $workerSurname, $birthDay, $dateOfEmployment){
     $qqq = $this-&gt;getEntityManager()
             -&gt;createQuery('SELECT w FROM OsdRetireBundle:Worker w 
                 WHERE w.omang LIKE :omang
                 AND w.workerName LIKE :WorkerName
                 AND w.workerSurname LIKE :workerSurname
                 AND w.birthDay LIKE :birthDay
                 AND w.dateOfEmployment LIKE :dateOfEmployment')
             -&gt;setParameter('omang', '%'.$omang.'%')
             -&gt;setParameter('WorkerName', '%'.$WorkerName.'%')
             -&gt;setParameter('workerSurname', '%'.$workerSurname.'%')
             -&gt;setParameter('birthDay', '%'.$birthDay.'%')
             -&gt;setParameter('dateOfEmployment', '%'.$dateOfEmployment.'%')
             -&gt;getResult();
     return $qqq;
  }
  </code></pre>
  
  <p>The error is the following:</p>
  
  <pre><code> Catchable Fatal Error: Object of class DateTime could not be converted to string in /var/www/Org/src/Osd/RetireBundle/Entity/WorkerRepository.php line 27
  500 Internal Server Error - ContextErrorException 
  </code></pre>
  
  <p>Am I supposed to convert with my own function the date to string? if so Where should I do it to make it reusable? any working example?
  I thought that Doctrine was able to do this automatically.
  Thak you in advenced.</p>