search

Home  >  Q&A  >  body text

How to check if input date exists between two date columns? Nodejs sequel

The date entered by the user is to check whether the date is between or exists between the start_Date column and the end_Date column of the MySQL database. Using NodeJS

P粉237689596P粉237689596240 days ago480

reply all(1)I'll reply

  • P粉547170972

    P粉5471709722024-03-31 20:45:48

    If you use Sequelize for this type of query, you can use the 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
        },
      }
    })
    

    reply
    0
  • Cancelreply