Skip to content

query mongoDb to substract timestamp

I want a query to subtract day from a Date. I test this:

{"lastSeen": { "$gte": {"$date": { $subtract: [ "$date", 1616000000 ] }}}}

But doesn’t work. I have this error on Gamesparks. Error parsing JSON. Please use valid JSON, including double-quotes on object keys.

Any ideas. Thank you.

Answer

As this is a JSON file, you will need to put $subtract in quotes.

{"lastSeen": { "$gte": {"$date": { "$subtract": [ "$date", 1616000000 ] }}}}