0
votes

I need a help on mongoid date range query.

I am trying to query events that spans over certain date range.

The event collection has two fields in the database start_date and end_date.

What would be the query to, for example, find events that occur between 04-18-2015 to 04-28-2015?

1

1 Answers

0
votes

This might be helpful to you :

db.collectionName.find({
"start_date": { $lt: endDate }, // add end date here
"end_date": { $gt: startDate } // add start date here
});