Sequelize query to find all records that falls in between date range

The solution which works for me is this:

// Here startDate and endDate are Date objects
const where = {
    from: {
        $between: [startDate, endDate]
    }
};

For reference to know more about operators: Querying, Operators

Note:

In MySQL, the between comparison operator is inclusive, which means it is equivalent to the expression (startDate <= from AND from <= endDate).

Leave a Comment