title: Sequelize query - compare dates in two columns
body: <p>I have a table in Sequelize with two date columns - i.e. with :</p>
  
  <pre><code>var Visit = sequelize.define("Visit", {
    /*...*/
    scheduleEndDate: {
      type: DataTypes.DATE
    }
    actualEndDate: {
      type: DataTypes.DATE
    }
    /*...*/
  });
  </code></pre>
  
  <p>I want to make a query that returns rows where actualEndDate is before scheduleEndDate - and can't get the format right. What I've tried for the <code>where</code> part of my <code>findAll</code> query is:</p>
  
  <pre><code>where: { actualEndDate: { lt: Visit.scheduleEndDate } }
  </code></pre>
  
  <p>- throws an error because Visit not defined (have also tried with this.scheduleEndDate - also throws an error)</p>
  
  <pre><code>where: { actualEndDate: '&lt; scheduleEndDate' }
  </code></pre>
  
  <p>- does a string comparison of actualEndDate against the string '&lt; scheduleEndDate'</p>
  
  <p>Do I need to define an instance method to do the date comparison / how best to solve?</p>