Find upcoming birthday using Sequelize

Viewed 496

I want to find upcoming birthday for every users based on 2 scenarios,

  1. In between Date1 to Date2.
  2. In between Current date to "N" months.

I was trying to implement this by,

{
        [Op.and]: [
            Sequelize.where(Sequelize.fn('DATE_FORMAT', Sequelize.col('user.dob'), '%m-%d'), {
                [Op.between]: [
                    moment(dateFrom).format('MM-DD'),
                    moment(dateTo).format('MM-DD')
                ]
            }),
        ]
    }

But this is not returning the expected results.

FYI, The data type of DOB is, dob: DataTypes.DATEONLY

0 Answers
Related