Mongoose Date Queries - Help

Hey y’all,
I’m trying to use the mongoose "greater than"and “less than” queries to find a date range.

db.posts.find({"created_on": {"$gte": start, "$lt": end}})

My data object has the date: new Date(2003-01-01)

date: "Wed Jan 01 2003 00:00:00 GMT+0000 (Coordinated Universal Time)"

I’m trying to query between 2002 and 2004, but the data object is still not returning:

          userid: req.userId,
          date: {
            $gte: new Date("2002-01-01"),
            $lt: new Date("2004-01-01")

I assume it has something to do with the way new Date() is formatted.


Any and all feedback is greatly appreciated!
Cheers :+1: