Help format MONGODB query in make

Hi - I Hope someone can help. This query works perfectly in MongoDB atlas and mongo compass:

{time: {$lt: ISODate(‘2022-11-10T18:09:23.000+00:00’)}}

the goal is to return documents created later than xyz. adjusted per your earlier suggestion, the query runs but no results:

{“time”: {“$lt”: ISODate(‘2022-11-10T18:09:23.000+00:00’)}}

I’ve tried everything I could possibly think of in regards to combinations without success. A screenshot I’ve included shows one of about 100 combos I tried.

However, a blank {} query does return results. Also, {“time”: “$exists”: true}} does return results. And if this post allows me to include a screenshot you will see an example. You may note shows the time field capitalized but I tested and that doesn’t work in a query. Also Make’s results show a different date format (time field is Date type) but I tried and that fails in queries too.

Creating a new post for better visibility, continuing this thread: Invalid Json Mongodb Search Documents - #3 by ryan_rockwood

ISODate() is a mongodb class, and not available in the JSON or in Make. However, you can use the parseDate function in make to get a date object, and then send the Unix timestamp representation of that to Mongodb.

Dates are always a point of complexity - perfectly normal for it to be a hard part. Share how it goes!

Do you think I can send a unix timestamp to mongo for the Date format shown? Or will I first need to create a unix timestamp field in mongo to query against?

What type are you storing that field as in mongo? The use case of an ISODate is to convert whatever the text is into a timestamp.

In mongo it’s described as a DATE field and the display is something like this: 2022-11-10T22:00:13.000+00:00

Oh so if ISODate doesn’t make sense, do you think I can sent it in as a unix timestamp with no quotes?

Still striking out, I wonder if anyone has had success with date queries through to Mongo?

Tried so far:
{ “date”: {“$lte”: {“$date”: “2022-11-06T00:05:21.486+00:00”}}}

{ “date”: “2022-11-06T00:05:21.486+00:00”}
{“creation_date”: { “$gte”: { “$date”: “1668200181”}}}
November 4, 2022 8:41 PM
{“isotime”: {“$lte”: {“date”: “1667576460”}}}
{“isotime”: {“$lte”: {“date”: “2022-11-06T00:05:21.486+00:00”}}}
{“date”: {“$lte”: “Date(2022-11-11T00:05:21.486+00:00)”}}
{“date”: {“$lte”: “Date(1667576460)”}}

You’re being very thoughtful about this! The thing I would try is passing the epoch value directly, like {“time”: {“$lt”: 1667576460000}}

Two things:

  1. As a number, no quotes required (assuming passing this way works).
  2. The epoch is in milliseconds, which is 1000x the scale of the examples you tried.

You are right about the milliseconds. Nice. Sadly, no luck yet today. I’m unable to pass any value through without quotes and avoid a json format error. Numerous values continue to return nothing and no error message.

No luck with the following:
{“isotime”: {“$lte”: {“date”: “1667576460”}}}
{“isotime”: {“$lte”: {“date”: “2022-11-06T00:05:21.486+00:00”}}}
{“date”: {“$lte”: “Date(2022-11-11T00:05:21.486+00:00)”}}
{“date”: {“$lte”: “Date(1667576460)”}}
{“IF30sec”: {“$exists”: true}}
{“time”: {“$lt”: 1667576460000}}

{“time”: {“$lt”: “2022-11-10T22:02:00.748Z”}}
{“time”: {“$lt”: November 10, 2022 2:02 PM}}
{“time”: {“$gte”: (November 10, 2022 2:02 PM)}}

{“filter”: {“time”: “November 10, 2022 2:02 PM”}}

{“time”: {“$lte”: “Date(1668281280000)”}}