Query MongoDB documents for a particular date range
Hi devs, I am trying to query documents based on particular date range. So I need all the documents where the createdDate is less than equal to current date and greater than equal to currentDate - 2.
I am assuming that there is some issue in the date format between how mongo db stores and how I am trying to fire that in the query.
Attached the screenshot. Can someone help



3 Replies
hage u tried console logging the 2 dates?
and see if they r correct of not?
With previous code I was not getting that format which I was seeing in mongoDB so I tried to tweak the code little bit.
Still not seeing the correct date after consoling.

I read it somewhere that I have to convert these into UTC format using ISOString method so I tried that.