Why the mongoose $lte operator does not work as expected for comparing dates?

Viewed 10

I am trying to compare dates to fetch records using mongoose query. The query is ,

var docsByDateRange = await expense.find({user_id:user_id,date_of_expense: { $gte: startDate, $lte: endDate } })

when I pass "endDate" in above query as a 31st of any month. The query fails to give expected result. It does not fetch record that has date something like "2022-03-31T11:32:40.000+00:00". Why? Does it have to do with timeZones n all?

0 Answers
Related