title: How to fetch last 24 hours records from database
body: <p>I have <code>Orders</code> model which stores orders of users. I'd like to filter only orders which has been issued (<code>order_started</code> field) on the last 24 hours for a user. I am trying to update following view:</p>
  
  <pre><code>def userorders(request):
      Orders = Orders.objects.using('db1').filter(order_owner=request.user).extra(select={'order_ended_is_null': 'order_ended IS NULL',},)
  </code></pre>
  
  <p>Order model has following fields:     </p>
  
  <pre><code>order_uid = models.TextField(primary_key=True)
  order_owner = models.TextField()
  order_started = models.DateTimeField()
  order_ended = models.DateTimeField(blank=True, null=True)
  </code></pre>
  
  <p>How can I add the extra filter?</p>