title: Rails Sql Query for MONTH AND YEAR
body: <p>I'm trying to show sales transactions for the current month and year in my index view.<br>
  This is what I've put in my sales controller:</p>
  
  <pre><code>def index
   @sales = show_sales_for_current_month(@sales)
  </code></pre>
  
  <p>which uses this method in the SalesHelper</p>
  
  <pre><code>def show_sales_for_current_month(sales)
    sales = Sale.find(:all,
                    :conditions =&gt; ["MONTH(date) = ? AND YEAR(date) =?",
                                    Date.today.month, Date.today.year])
  end
  </code></pre>
  
  <p>where date is a date data type.</p>
  
  <p>but i'm getting the following controller error: </p>
  
  <pre><code>SQLite3::SQLException: no such function: MONTH: SELECT "sales".* FROM "sales" WHERE (MONTH(date) = 4 AND YEAR(date) =2011)
  </code></pre>
  
  <p>I've looked around at posts and it seems like that is the correct function, so what am I doing wrong?  Thanks!</p>