MongoDB: How to do any consult with dates ?

First you need save in date format in your MongoDB.


var dtStart = new Date(moment(dts).format("MM/DD/YYYY HH:MM"));
var dtEnd = new Date(moment(dte).format("MM/DD/YYYY HH:MM"));

var period = {



Example :

return Events.find({places: { $exists: true },places:{$in:idPlaces},category:category,'sessions.dt_start': { $exists: true },'sessions.dt_start':{$gte:dtStart,$lte:dtEnd}},{sort:{createdAt: -1}});

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s