title: MySQL getting last month instead of specific week
body: <p>I have this part of my SQL-statement where I select the one week depending on the input date:</p>
  
  <pre><code>SELECT DATE_FORMAT(md.`mydate`, '%d.%m.%Y'),
  ...
  DAYNAME(md.`mydate`) FROM `mydates` md
  LEFT JOIN (SELECT * FROM `import` 
      WHERE `Zeitspanne` != 'Anwesenheit' 
      AND `Person` = '".mysql_real_escape_string($expName)."') g 
      ON (md.`mydate` =  STR_TO_DATE(g.`Datum`, '%d.%m.%Y') )
  WHERE WEEK(md.`mydate`,1) = WEEK('".$getStart[2].$d.$getStart[1].$d.$getStart[0]."',1)
  AND YEAR(md.`mydate`) = YEAR('".$getStart[2].$d.$getStart[1].$d.$getStart[0]."')";
  </code></pre>
  
  <p>Now I want to select the last month (in this case September) instead of the user-specific week like this:</p>
  
  <pre><code>LEFT JOIN (
      SELECT * FROM `import` 
      WHERE `Zeitspanne` != 'Anwesenheit' 
      AND `Person` = '".mysql_real_escape_string($expName)."') g 
      ON (md.`mydate` =  STR_TO_DATE(g.`Datum`, '%d.%m.%Y') )
  WHERE MONTH(md.`mydate`,1) = MONTH('".$getStart[2].$d.$getStart[1].$d.$getStart[0]."' - INTERVAL 1 MONTH)) 
  AND YEAR(md.`mydate`) = YEAR('".$getStart[2].$d.$getStart[1].$d.$getStart[0]."' - INTERVAL 1 MONTH)";
  </code></pre>
  
  <p>...but it seems not to work.</p>