Query from MongoDB with date fields

I have a collection in MongoDB that is linked to my retool. This collection has documents with date field. I'm having trouble applying a query to find records between dates.
Seems that Retool reports the date field is of 'document' type, and applying any query condition on it, such as $gte or $lt does not return any value.
Tried to search through the docs, but many links point to v1 or v2 JSON queries, which I'm not sure how to write or apply.

1 Like

Hey @daniel123!

A typical date filter might look something like this:

[
  {
    "$match": {
      "your_date_field": {
        "$gte": {
          "$date": "your_filter_value"
        }
      }
    }
  }
]

Is that what you already have?

2 Likes

Thanks - this was very helpful!

(In case anyone else tries this out, you need to have the query action type set to 'Aggregate' to use this syntax, rather than a regular 'find' action type).

1 Like