In MongoDB node unable to Query data based on Date Field

Hi Team,

I am unable to query data in mongoDB node using data field.
Earlier I have tried following query techniques to filter the data-

{"propertyId":"AGA00062","source":"bookingCom","status":{"$ne":"Cancelled"},"checkInDate":"2022-11-03T00:05:00.000Z"}
{"propertyId":"AGA00062","source":"bookingCom","status":{"$ne":"Cancelled"},"checkInDate":{"$eq":"2022-11-03T00:05:00.000Z"}}
{"propertyId":"AGA00062","source":"bookingCom","status":{"$ne":"Cancelled"},"checkInDate":{"$eq":{"$date":"2022-11-03T00:05:00.000Z"}}}

Finally, I found a method to use “$expr” in one of the community threads, which was working fine until someday back for the same query, I am receiving the following error.

Query-

{
"$expr":{

"$and":[

{"$eq":["$checkInDate",{ "$dateFromString": { "dateString": "2022-11-06T00:05:00.000Z"}}]},

{"$eq":["$propertyId","AGA00062"]},

{"$eq":["$source","bookingCom"]},

{"$ne":["$status","Cancelled"]}
]
}

Error Message -

Can someone please help out with this.

PS: There has been multiple threads on community complaining about the similar issue

Thanks,

@jan @MutedJam @Jon
Can anyone please help me out with this.

Thanks

Hi @Mustafa_Ali, please do not at-mention folks on the forum if you simply have a new question. Things are really busy at the moment, so we can’t attend to each post straight away. I’ll still try to look through all posts without replies when I have the chance.

That said, it’d be tremendously helpful if you would provide the information requested in the question template on the forum rather than just deleting it. In particular sharing an example workflow using which your problem can be reproduced and confirming the exact version of n8n you are running would be helpful. Seeing you are having trouble with a database you might also want to describe how exactly your data looks like.

Lastly, since you mentioned this worked in the past, can you please confirm what has changed between the working and not working state? Did you upgrade n8n or your database? If so, from which version did you upgrade and which version are you running now?

Hi @Mustafa_Ali, I tried finding the below dataset from MongoDB:

image

This works fine using the below workflow on [email protected] which queries the created_at date field from my example:

Result:

So, it’d be good to understand what exactly is needed to reproduce your problem (specifically MongoDB version, n8n version, workflow, data structure).

If you’re using another n8n version than 0.201.0 you could also try upgrading first to verify whether this resolved the problem.