0

I need to send birthday wishes to users in my application.

I have a table "userdetails" with the column "dob". I need a query to retrieve users having a date of birth matching today's date.

For example, if a user has a "dob" value "1991-01-21 00:00:00", I have to send a birthday email to the user.

const users = await userdetails.find({
 where: {
   dob: "  " // not sure what goes in there
 },
});

Here, I am not sure what I can put in the where field to match my query.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • 1
    Welcome to Stack Overflow! Visit the [help], take the [tour] to see what and [ask]. If you get stuck, post a [mcve] of your attempt, noting input and expected output using the [`[<>]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Jan 20 '22 at 09:14

1 Answers1

1

If column type is date, the code will probably be like this:

where: {
    dob: new Date().toISOString().slice(0,10), // '2022-01-25'
},
Nimantha
  • 6,405
  • 6
  • 28
  • 69
akadirdev
  • 70
  • 7