Adding/Subtracting days to ISODate in MongoDB Shell

This has been answered on Query to get last X minutes data with Mongodb

query = {
    timestamp: { // 18 minutes ago (from now)
        $gt: new Date(ISODate().getTime() - 1000 * 60 * 18)
    }
}

And in your case, for a number of days:

"StartDate" : { "$gte" : new Date(ISODate().getTime() - 1000 * 3600 * 24 * 3) }

or

"StartDate" : { "$gte" : new Date(ISODate().getTime() - 1000 * 86400 * 3) }

(here the 3 is your number of days)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)