New to SQL, having an issue with a calculated date column I want to insert in my query. I want to add 45 days to each date in the OOEXD column. The closest I can get to something working is below. Should I solve for the error message or is there a better syntax ? Thanks
select OOEXD AS [TERM DATE], DATEADD(day, 45, ooexd) AS [45 DAY]
from [Table]
Error: Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type datetime.
declare @var decimal(8) = 2958419.00
select DATEADD(DAY,45,@var) Msg 517, Level 16, State 1, Line 3 Adding a value to a 'datetime' column caused an overflow.
From above results my understanding is the decimal is implicitly converting to datetime date type and then applying dateadd function. from above results the maximum decimal value allowed in your case is "2958418" for decimal (8). May be for one of your table row the column "OOEXD" value exceeds this boundary value.