HTTP request filter by date

Hi
I am using an HTTP request module to access MongoDB.
I am trying to filter records based on a date range.
The date field in MDB is called createdAt and it has values like this:
2023-10-19T14:12:56.791+00:00
I cannot retrieve any data.
This is my debug query:
{
“database”: “{{1.MONGO_DB}}”,
“dataSource”: “{{1.MONGO_DATASOURCE}}”,
“collection”: “userEvent”,
“filter”: {
“createdAt”: “2023-10-19T14:12:56.791+00:00”
}
}
This returns no documents and yet the date has been lifted directly from MDB.
I have tried to parse the date in make.com
{{parseDate(“2023-10-19T14:12:56.791+00:00”; “YYYY-MM-DDTHH:mm:ss.SS”; “GMT”)}}

But the output of this looks like this: 2023-10-19T14:12:56.791Z
This does not work I am guessing because of the Z which make.com inserts
I tried this too: {{parseDate(“2023-10-19T14:12:56.791”; “YYYY-MM-DDTHH:mm:ss.SS”; “GMT”)}}, same problem

Any ideas plse?
Thx
Ian

PS I am assuming once i crack this i can use $gte and $lt for my date range.

For the benefit of the community I finally managed to crack this one. The target date is createdAt:

“filter”: {
“createdAt”: {
“$gte”: {
“$date”: “2023-10-20T23:00:00+00:00”
},
“$lte”: {
“$date”: “2023-11-01T23:00:00+00:00”
}
}
}
et voila!

3 Likes

Hello there @dude :wave:

I just wanted to quickly jump in to say awesome work figuring this one out on your own :clap:

Also, thanks so much for stepping back in here and sharing what did the trick for you with the rest of us. This is super valuable stuff :pray:

Just FYI: I marked your reply as a solution to keep the community organized and to make it easier for others to find answers to their questions :white_check_mark:

1 Like