I have a table in Sequelize with two date columns - i.e. with :
var Visit = sequelize.define("Visit", {
/*...*/
scheduleEndDate: {
type: DataTypes.DATE
}
actualEndDate: {
type: DataTypes.DATE
}
/*...*/
});
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 where
part of my findAll
query is:
where: { actualEndDate: { lt: Visit.scheduleEndDate } }
- throws an error because Visit not defined (have also tried with this.scheduleEndDate and scheduleEndDate - also throw an error)
where: { actualEndDate: '< scheduleEndDate' }
- does a string comparison of actualEndDate against the string '< scheduleEndDate'
Do I need to define an instance method to do the date comparison / how best to do this query?