Skip to content
Advertisement

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.

Advertisement

Answer

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

{"lastSeen": { "$gte": {"$date": { "$subtract": [ "$date", 1616000000 ] }}}}
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement