title: Access SQL - given two dates, return the dates of the previous period
body: <p>I need to find the dates of the preceding time period - e.g. if the given months are Jan-13 to Mar-13, I need to be able to calculate that the previous period is Oct-12 to Dec-12. Or if the dates are Jul-12 to Jun-13, I need to come up with Jul-11 to Jun 12. So basically for a time period of x months, I need to return another time period of x months that finishes the month before the specified time period.</p>
  
  <p>The date will always be the first of the month, so 1st June 2012 or 6/1/2012 or 1/6/2012 depending on where you are in the world.</p>
  
  <p>This SQL query works, but seems to be causing problems later on when I incorporate it in a Left Join query (see existing question: <a href="https://stackoverflow.com/questions/17170426/access-2007-left-join-to-a-query-returns-error-instead-of-null">Access 2007 - Left Join to a query returns #Error instead of Null</a>)</p>
  
  <pre><code>SELECT DATEADD("m",
  1-(1+MONTH(QueryDates.EndDate)-MONTH(QueryDates.StartDate)+
      (12*(YEAR(QueryDates.EndDate)-YEAR(QueryDates.StartDate)))),
  DATEADD("m",-1,QueryDates.StartDate)) AS StartDatePrevious, 
  DATEADD("m",-1,QueryDates.StartDate) AS EndDatePrevious
  FROM QueryDates;
  </code></pre>
  
  <p>It looks a bit crazy from where I'm sitting, so is there a simpler way of achieving this task; or is there anything wrong in the SQL that could confuse Access later on?</p>