title: Rails query for Data over the past months
body: <p>I am trying to query for the number of messages sent over the last months, i use something like this to find out the last 6 months by name</p>
  
  <pre><code>gon.now_month_label = (Date.today).strftime("%B")
  gon.now_month_data = 
  gon.one_month_ago_label = (Date.today - 1.month).strftime("%B")
  gon.one_month_ago_data = 
  gon.two_months_ago_label = (Date.today - 2.month).strftime("%B")
  gon.two_months_ago_data = 
  gon.three_months_ago_label = (Date.today - 3.month).strftime("%B")
  gon.three_months_ago_data = 
  gon.four_months_ago_label = (Date.today - 4.month).strftime("%B")
  gon.four_months_ago_data = 
  gon.five_months_ago_label = (Date.today - 5.month).strftime("%B")
  gon.five_months_ago_data = 
  </code></pre>
  
  <p>But also need the corresponding data.</p>
  
  <p>I tried something like this</p>
  
  <pre><code>gon.now_month_data = SentMessage.where(created_at.month: (Date.today).strftime("%B") ).count
  </code></pre>
  
  <p>But it failed.Besides it can search for others years and not exactly a month ago.
    Any idea of how i can construct Queries to get the information.</p>
  
  <p>We need to have data like say November : 2034 messages and October: 5330</p>