0

I'm having problem while trying to filter results from the database with the provided date,as stated in mongoose documentation

const { createdAt } = req.query
const user = await User.find({ createdAt: new Date(createdAt) })

The above implementation returns an empty array, because if I pass in 2021-08-05 in the query param which is converted to 2021-08-05T00:00:00.000+00:00 before a comparison is done, That does not tally with the date in the DB(2021-08-05T18:59:58.324+00:00).

Someone please assist on how to fetch the specific Date.

Fehmy
  • 55
  • 9

0 Answers0