title: T-SQL datetime conversion
body: <p>I'm working with a 3rd party database, which (for whatever reason) internal stores a date in the format <code>yyyymm</code> eg <code>201212</code> for <code>Dec 2012</code> as an <code>INT</code>.</p>
  
  <p>Is there a simple way that I may convert this to a SQL Server <code>DateTime</code> type?</p>
  
  <p>I've tried manually converting the above to a char seq of length 6, concatenating this with '01' to get the start of a given month like so: </p>
  
  <pre><code>(CONVERT(char(6), Period) + '01')`
  </code></pre>
  
  <p>then wrapping this in a <code>datetime</code> conversion: </p>
  
  <pre><code>CONVERT(datetime, (CONVERT(char(6), Period) + '01'))
  </code></pre>
  
  <p>but this seems to throw; </p>
  
  <blockquote>
    <p><em>Conversion failed when converting date and/or time from character string</em></p>
  </blockquote>
  
  <p>Can anyone shed any light on what I'm doing wrong?</p>
  
  <p>Thanks! :)</p>