title: SQLAlchemy - Querying with DateTime columns to filter by month/day/year
body: <p>I'm building a Flask website that involves keeping track of payments, and I've run into an issue where I can't really seem to filter one of my db models by date.</p>
  
  <p>For instance, if this is what my table looks like:</p>
  
  <pre><code>payment_to, amount, due_date (a DateTime object)
  
  company A, 3000, 7-20-2018
  comapny B, 3000, 7-21-2018
  company C, 3000, 8-20-2018
  </code></pre>
  
  <p>and I want to filter it so that I get all rows that's after July 20th, or all rows that are in August, etc.</p>
  
  <p>I can think of a crude, brute-force way to filter all payments and THEN iterate through the list to filter by month/year, but I'd rather stay away from those methods.</p>
  
  <p>This is my payment db model:</p>
  
  <pre><code>class Payment(db.Model, UserMixin):
      id = db.Column(db.Integer, unique = True, primary_key = True)
  
      payment_to = db.Column(db.String, nullable = False)
      amount = db.Column(db.Float, nullable = False)
  
      due_date = db.Column(db.DateTime, nullable = False, default = datetime.strftime(datetime.today(), "%b %d %Y"))
      week_of = db.Column(db.String, nullable = False)
  </code></pre>
  
  <p>And this is me attempting to filter <code>Payment</code> by date:</p>
  
  <pre><code>Payment.query.filter(Payment.due_date.month == today.month, Payment.due_date.year == today.year, Payment.due_date.day &gt;= today.day).all()
  </code></pre>
  
  <p>where <code>today</code> is simply <code>datetime.today()</code>.</p>
  
  <p>I assumed the <code>due_date</code> column would have all DateTime attributes when I call it (e.g. <code>.month</code>), but it seems I was wrong.</p>
  
  <p>What is the best way to filter the columns of <code>Payment</code> by date? Thank you for your help.</p>