# Mongoose Date Queries - Help

**URL:** <https://forum.freecodecamp.org/t/mongoose-date-queries-help/350553>\
**Category:** General\
**Created:** [February 16, 2020, 1:39am UTC](https://forum.freecodecamp.org/t/mongoose-date-queries-help/350553 "2020-02-16T01:39:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bstefansen](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bstefansen/32/143007_2.png) [@bstefansen](https://forum.freecodecamp.org/u/bstefansen)\
**Post date:** [February 16, 2020, 1:39am UTC](https://forum.freecodecamp.org/t/mongoose-date-queries-help/350553/1 "2020-02-16T01:39:28Z")

</div>

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

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

```

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

```auto
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:

```auto
exerciseModel
      .find(
        {
          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.

Project: [https://glitch.com/edit/#!/exercise-tracker-stefansen](https://glitch.com/edit/#!/exercise-tracker-stefansen)

Any and all feedback is greatly appreciated!  
Cheers 👍

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 7:35pm UTC](https://forum.freecodecamp.org/t/mongoose-date-queries-help/350553/2 "2021-06-01T19:35:32Z")

</div>

Closed on June 1, 2021, 7:35pm UTC


