title: SQL Server error - Adding a value to a 'datetime' column caused an overflow
body: <p>I'm using SQL Server 2014. The last line causes causes an overflow error. </p>
  
  <p>Why?      </p>
  
  <pre><code>  DECLARE @CurrentDateTime  datetime
    DECLARE @PreviousYearDateTime  datetime
    DECLARE @ModifiedStartDateTime  datetime
    DECLARE @YearsYear   int = 2015
  
    SET @CurrentDateTime = '2016-08-29 19:13:30.840'      
    SET @PreviousYearDateTime = CONVERT(datetime, DATEADD(YEAR, -1, @CurrentDateTime))
  
    -- For the "startdate" - just use the previous "startdate".
    SET @ModifiedStartDateTime = @PreviousYearDateTime
  
    -- Set the 'year' to the year value.
    SET @ModifiedStartDateTime = DATEADD(YEAR, @YearsYear, DATEADD(YEAR, -DATEPART(YEAR, @ModifiedStartDateTime), @ModifiedStartDateTime))
  </code></pre>