Skip to content
Advertisement

sequelize compare date with date-timestamp

my simple use case is I pass a date and try to compare that with the default createdAt column.

and my date is a string like this date = '2018-12-12'

The problem here is sequlize not compare only the date. But it does add time 00:00:00 to my date and then compare. So the query sequlize generate is like this.

What I deserved

How do I achieve this using sequlize?

Advertisement

Answer

I think you would want something more like:

Which would give SQL syntax like (note the wildcard):

Operators can give you a broad range of SQL syntax equivalents, additionally I think the shorthand you are using is deprecated so I subbed in the Op syntax you might need that as sequelize.Op if you aren’t destructuring your variables.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement