MongoDB criteria: all data newer than current timestamp - 90 Days
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I try to select all rows from a MongoDB, where the field "updatedOn" (Format: DateTime) is newer than the current Time - 90 Days.
My first try was:
{"updatedOn": {"$gt": new Date(ISODate().getTime() - 1000 * 3600 * 24 * 90)} }
That gives me a parsing Error to JSON. Error: MongoDB Input (1): Got parse error at "D", position 28: "SPECIAL_EXPECTED": could not parse JSON document
Is it not possible to use thenew Date(ISODate().getTime() ? Or does anybody knows what I'm doing wrong ?
Thx
Patrik
- Labels:
- MongoDB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Could you select All records from Mongo and use a standard Filter tool to do the T - 90? Not the most efficient, but when it comes to Mongo, I am happy to settle for 'it works'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yes, we could do that... that would work, but the main reason for this "updatedOn" Timestamp is that we don't have to read the whole Database. We have a performance issue with the MongoDB.
