Brah Pl
0
Q:

mongodb subtract dates

// 2 days before
"StartDate" : { "$lt" : new Date(ISODate().getTime() - 1000 * 86400 * 2) }
1
query = {
    timestamp: { // 18 minutes ago (from now)
        $gt: new Date(ISODate().getTime() - 1000 * 60 * 18)
    }
}
1
db.sales.aggregate( [ { $project: { item: 1, total: { $subtract: [ { $add: [ "$price", "$fee" ] }, "$discount" ] } } } ] )
0

New to Communities?

Join the community