2020-04-27

MongoDB - Filter for documents dated in the last 30 days

db.collection_name_here.find({
    "date_field_name_here": { 
        $gte: new Date(
            (
                new Date().getTime() 
                - (30 * 24 * 60 * 60 * 1000)
            )
        ) 
    },
});

No comments:

Post a Comment