title: getting the previous month on the last day of the month.
body: <p>I have a query that i run each day at 3 AM to give me the sales of the current month. </p>
  
  <p>The problem arise at the last day of each month. Because the month has already flipped. 
  So when i run at 1st November 3 AM it gives 0. Whereas it should give me the sales of October.
  Here is the query. </p>
  
  <pre><code>SELECT COUNT(order_id) AS added_orders
  FROM `order`
  WHERE date_added &gt; DATE_ADD(CURDATE(), INTERVAL -31 DAY)
  AND order_status_id != 0
  AND MONTH(date_added)= MONTH(curdate())
  </code></pre>
  
  <p>Any Ideas ? </p>