1

in the database I have a column called, edited date. I need to write a query.

 where: {
           lastEditedDateTime:!moment().subtract(10, 'days').toDate()
}

I need to write query that finds the last edited date is greater than 10 days.

Prash
  • 27
  • 4
  • You need a `lt` operator for that: https://sequelize.org/master/manual/model-querying-basics.html#operators –  Nov 03 '20 at 13:41
  • Does this answer your question? [Sequelize Where statement with date](https://stackoverflow.com/questions/29798357/sequelize-where-statement-with-date) –  Nov 03 '20 at 13:42
  • @ChrisG no it doesnt – Prash Nov 03 '20 at 13:45
  • The accepted answer shows exactly how to do that, doesn't it? (also: "Does this answer your question?" is auto-inserted when you mark a question as dupe, I didn't type that myself, just fyi) –  Nov 03 '20 at 13:47
  • @chrisG im a begineer. sorry – Prash Nov 03 '20 at 14:30

1 Answers1

1

I think this is what you're looking for.

where: {
  lastEditedDateTime: {
    [Op.lte]: moment().subtract(10, 'days').toISOString() 
  }
}

Here are the search operators in Sequelize: https://sequelizedocs.fullstackacademy.com/search-operators/.

jeffbumgardner
  • 116
  • 1
  • 4
  • The question is already marked as dupe, pointing to [this answer](https://stackoverflow.com/a/33061376/5734311) –  Nov 03 '20 at 13:47