I have a model (Events) with five years worth of records (one record per day). I need a method that, when passed a date object such as 2011-12-25 00:00:00, will show me ALL the records that have happened on 12/25 (querying against the :created_at column), regardless of the year or time that's passed.
I tried the following query to retrieve data that are in between given date but i got an issue after year change my query not able to retrieve records. for example record sdate="1-06-2013" and edate ="2-2-2014" i want records of 1st January then how can i get this data.
db.events.find( "this.sdate.getMonth() > 6 && this.edate.getMonth() < 6" );
I need exact following query using in Mongoid rather than ActiveRecord
Model.where("MONTH(created_at) = ? and DAY(created_at) = ?", somedate.month, somedate.day)