 <p>In mongoid you can use between to do a search of records within a range. I don't recommend that you do the filtering directly in Ruby as this will be slow and memory intensive for larger data set.</p> <p>This post goes through a solution:</p> <p><a href="http://stackoverflow.com/questions/8136652/query-mongodb-on-month-day-year-of-a-datetime">Query Mongodb on month, day, year... of a datetime</a></p> <p>However, if you want to do it in pure ruby you could do:</p> <pre><code>start, finish = "06:00~09:00".split('~') start_hour = start.split(':')[0].to_i end_hour = finish.split(':')[0].to_i flights.select do |flight| flight.departure_time.hour &gt;= start_hour &amp;&amp; flight.departure_time.hour &lt;= end_hour end </code></pre> <p>This will just query for hours. You can include minutes by doing:</p> <pre><code>start, finish = "06:00~09:00".split('~') start = start.split(':').map(&amp;:to_i) finish = finish.split(':').map(&amp;:to_i) # Work in minutes start_minutes = start[0] * 60 + start[1] finish_minutes = finish[0] * 60 + finish[1] flights.select do |flight| dep_mins = flight.departure_time.hour * 60 + flight.departure_time.min dep_mins &gt;= start_minutes &amp;&amp; dep_mins &lt;= finish_minutes end </code></pre>