javascriptnode.jspostgresqlsequelize.jstimestamp-with-timezone

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?


Solution

  • try using the sequelize.fn() argument, you can follow example code below.

    TableName.findAll({
      where: sequelize.where(sequelize.fn('date', sequelize.col('createdAt')), '=', '2018-11-07')
    })