title: MYSQL Query select date ranges which are stored in unix timestamps
body: <p>I'm attempting to pull a section of data from a table with dates stored as unix timestamps. The trouble I'm having in particular is the WHERE line. I'd like get all rows with the current year and month.</p>
  
  <pre><code>SELECT COUNT(rebuild_quote) AS total, resources.name, reservations.machid,
  YEAR(FROM_UNIXTIME(start_date) + INTERVAL 4 DAY) AS year,
  MONTH(FROM_UNIXTIME(start_date) + INTERVAL 4 DAY) AS month,
  SUM(CASE WHEN rebuild_quote = 'Won' THEN 1 ELSE 0 END) AS won,
  SUM(CASE WHEN rebuild_quote = 'Lost' THEN 1 ELSE 0 END) AS lost,
  SUM(CASE WHEN rebuild_quote = 'Won' THEN 1 ELSE 0 END) + SUM(CASE WHEN rebuild_quote = 'Lost' THEN 1 ELSE 0 END) AS total,
  SUM(CASE WHEN rebuild_quote = 'Won' THEN 1 ELSE 0 END) / (SUM(CASE WHEN rebuild_quote = 'Won' THEN 1 ELSE 0 END) + SUM(CASE WHEN rebuild_quote = 'Lost' THEN 1 ELSE 0 END)) * 100 AS conversion
  FROM reservations
  LEFT JOIN resources
          ON reservations.machid = resources.machid
  
  **WHERE YEAR(start_date) = YEAR(UNIX_TIMESTAMP(NOW())) AND MONTH(start_date) = MONTH(UNIX_TIMESTAMP(NOW()))**
  GROUP BY
        YEAR(FROM_UNIXTIME(start_date) + INTERVAL 3 DAY), MONTH(FROM_UNIXTIME(start_date) + INTERVAL 3 DAY), machid
  ORDER BY year DESC, month DESC
  </code></pre>
  
  <p>Thanks in advance.</p>