how to check input date exist in between two date column or not? nodejs sequelize

Viewed 19

the date user entered is to check the date is between or exist in start_Date column and end_Date column in MySQL db. using NodeJS

1 Answers

If you use Sequelize to make such query then you can use Op.gte and Op.lte operators to achieve these two comparisons:

const records = model.findAll({
  where: {
    start_Date: {
      [Op.lte]: date
    },
    end_Date: {
      [Op.gte]: date
    },
  }
})
Related