Error when using gte with a date from mongo shell

I am getting an error when I try to use a gte with a date, in a find. What am I doing wrong?

I am trying to find records in the last 7 days.

db.XXXX.find({"lastSaved":{$gte: new Date(new Date() - 7 * 60 * 60 * 24 * 1000)}}).sort({"lastSaved" : -1})

syntax error near unexpected token `{“lastSaved”:{$gte:’

This query is not generating an error message on my system.

Please provide a screenshot of where and how you issue this query that shows the error message you are getting.

I just realized I had exited the mongo shell and was in bash, without realizing it.

The query works.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.