title: Django filter based on start date and end date for single day
body: <p>I have a query </p>
  
  <pre><code>start_date = '2019-11-17'
  end_date = '2019-11-18'
  
  events = Event.objects.filter(start_date__gte=start_date,end_date__lte=end_date)
  </code></pre>
  
  <p>This doesn't return any result.. I tried direct mysql query, even this doesn't return any results,</p>
  
  <pre><code>SELECT * FROM `events` where start_date &gt;= '2019-11-17' and end_date &lt;= '2019-11-18'
  </code></pre>
  
  <p>Any idea where I am wrong?</p>
  
  <p>In my database I have these 3 rows,</p>
  
  <p><a href="https://i.stack.imgur.com/0JI59.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0JI59.png" alt="enter image description here"></a></p>
  
  <p>This works,</p>
  
  <pre><code>SELECT * FROM `events` where start_date &gt; '2019-11-17' and end_date &lt; '2019-11-19'
  </code></pre>
  
  <p>But why not <strong>&lt;= '2019-11-18'</strong>?? any idea?</p>
  
  <p>I managed to add 1 day to the end_date to resolve it.</p>
  
  <p><strong>MY SOLUTION</strong></p>
  
  <pre><code>start_date = datetime.fromtimestamp(start_date/1000.0)
  end_date = datetime.fromtimestamp(end_date/1000.0)
  
  start_date = start_date.strftime('%Y-%m-%d')
  end_date = (end_date + timedelta(days=1)).strftime('%Y-%m-%d')
  </code></pre>
  
  <p>NOW THIS WORKS</p>
  
  <pre><code>events = Event.objects.filter(start_date__gt=start_date,end_date__lt=end_date)
  </code></pre>