title: Last 13 full months SQL WHERE clause
body: <p>I have a database with a date column that logs when a new "contact" is created. The contacts are generated when the call center receives a new call or e-mail. </p>
  
  <p>What I want is for the where clause to capture the last 13 months of full data. </p>
  
  <p>Examples: </p>
  
  <ul>
  <li>Today is 1/30/2015, if executed the query would return records from 12/1/2013 to 12/31/2014.  </li>
  <li>Today is 2/06/2015, if executed the query would return records from 1/1/2014 to 1/31/2015.  </li>
  <li>The query will include those dates falling on the first and last days of the month.</li>
  </ul>
  
  <p>The code I have is as follows: </p>
  
  <pre><code>WHERE 
     dbo.ub_contact.contact_dt BETWEEN DATEADD(year, -1, (DATEADD(month, DATEDIFF(month, -1, getdate()) - 1, -1) + 1)) 
                               AND DATEADD(month, DATEDIFF(month, -1, getdate()) - 1, -1)
  </code></pre>
  
  <p>Ran today (1/30/2015) this code seems to be returning 1/1/2014 - 12/31/2014. </p>
  
  <p>I would appreciate any help toward getting this worked out. </p>
  
  <p>Thanks! </p>
  
  <p>John </p>