title: SQL Server Converting int to Date
body: <p>I have a scenario where I have an int column with the following dates for example:</p>
  
  <p>20131210</p>
  
  <p>20131209</p>
  
  <p>What I want is, I want to convert the above to a date datatype so that I can use it with GETDATE() function.
  This is my try but I am getting an error:</p>
  
  <pre><code>SELECT CONVERT(DATETIME, CONVERT(varchar(8), MyColumnName))
  FROM MyTable
  WHERE DATEADD(day, -2, CONVERT(DATETIME, CONVERT(CHAR(8), MyColumnName))) &lt; GetDate()
  </code></pre>
  
  <p>This is the error I am getting:</p>
  
  <p>Conversion failed when converting date and/or time from character string.</p>