DATEADD function Issue when 2nd argument exceeds int limit

Posted by Bandi under Sql Server category on | Points: 40 | Views : 467
 SELECT DATEADD(year,2147483648, '2014-07-31')
,DATEADD(year,-2147483649, '2014-07-31')

the above statement will throw the error
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.

this is due to the second argument of DATEADD fucntion i sint. So it should not exceed int max/min range value

Comments or Responses

Login to post response