Arithmetic overflow error converting expression to data type int.

When I used to add seconds as bigint value in DateAdd then it is throwing error as Arithmetic overflow error converting expression to data type int.

SELECT DATEADD(SS,2148595199,’1970-01-01′)

Msg 8115, Level 16, State 2, Line 1

Arithmetic overflow error converting expression to data type int.

The Bigint 2148595199 is basically the difference between 1970-01-01 and 2038-01-31 23:59:59

SELECT DATEDIFF_BIG(ss,’1970-01-01‘,’2038-01-31 23:59:59‘)

To Resolved this error

I used this command

SELECT DATEADD(DAY, 2148595199 / (86400), ‘1970-01-01 23:59:59’)

Where 86400 = 24 * 60 * 60

In a day total seconds are 86400

Read more here: Source link