title: Check if date already exists in another time period
body: <p>I have a page where an admin can create new periods of time. Now when the admin wants to add a new period I would like to check if there isn't another period already.</p>
  
  <p>This is my current code, but I guess <code>&lt;=</code> and <code>&gt;=</code> don't work like they should in doctrine?</p>
  
  <pre><code>$formMapper-&gt;getFormBuilder()-&gt;addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event) {
    try {
      $from = str_replace('/', '-', $event-&gt;getData()['from']);
      $to = str_replace('/', '-', $event-&gt;getData()['to']);
  
      $dateFrom = new \DateTime($from, new \DateTimeZone('Europe/Amsterdam'));
      $dateFrom = $dateFrom-&gt;format('Y-d-m');
  
      $dateTo = new \DateTime($to, new \DateTimeZone('Europe/Amsterdam'));
      $dateTo = $dateTo-&gt;format('Y-d-m');
  
      $query = $this-&gt;getModelManager()-&gt;createQuery('PeriodeBundle:Periode', 'p');
  
      $query-&gt;select()
        -&gt;where(':from = p.from')
        -&gt;andWhere(':to = p.to')
        -&gt;setParameter('from', $dateFrom)
        -&gt;setParameter('to', $dateTo);
  
      $data = $query-&gt;execute();
  
      if (count($data) &gt; 0) {
        $event-&gt;getForm()-&gt;addError(new FormError('This period overwrites another existing period ('
           . $data[0]-&gt;getFrom()-&gt;format('d/m/Y') . ' to '
           . $data[0]-&gt;getTo()-&gt;format('d/m/Y') . ')'));
      }
    } catch (\Exception $e) {
        $event-&gt;getForm()-&gt;addError(new FormError('Date not valid'));
    }
  
  
   });
  </code></pre>
  
  <p>In my database I have several periods simplified like this: <code>period_id, from, to</code></p>
  
  <p>Can someone point me in the right direction?
  My data is NULL when I create a period which already exist, and when I add a period in the far future it gives me a result of all rows.
  <strong>I read about <code>lte</code> and <code>gte</code> but I dont quite know how to integrate that in this code.</strong></p>
  
  <p>This code is in my Admin of my PeriodBundle.</p>