title: The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value - Leap Year
body: <p>I get this error in stored procedure code and I discovered one of the records is from a leap year date 2008-02-29. How do I get around this with the code I have. Here is the code:</p>
  
  <pre><code>set @ContractDate = cast(cast(@Year as nvarchar(4))
  + '/' + cast(datepart(mm,@ContractDate) as nvarchar(2))
  + '/' + cast(datepart(dd,@ContractDate) as nvarchar(2)) as datetime)
  </code></pre>