 <p><a href="http://railscasts.com/episodes/29-group-by-month" rel="nofollow">http://railscasts.com/episodes/29-group-by-month</a></p> <pre><code>NewsFeed.where("user_id is not in (?)",[user_ids]).group_by { |t| t.created_at.beginning_of_month } =&gt; each {|month,feed| ...} NewsFeed.select("*,MONTH(created_at) as month").where("user_id is not in (?)",[user_ids]).group("month") =&gt; ... </code></pre>