Skip to content
Advertisement

Compare Timestamp with date in sequelize query

I have createdAt column which stores value as "2018-11-07 15:03:16.532+00". I want to write query like select * from table_name where createdAt = input_date, where myinput_date is only date value like 2018-11-07. How do i write this query using Sequelize?

Advertisement

Answer

try using the sequelize.fn() argument, for example like this, try adjusting it.

Ex:

TableName.findAll({
  where: sequelize.where(sequelize.fn('date', sequelize.col('createdAt')), '=', '2018-11-07')
})
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement