What's the right way to cast the query below to escape this datatype error:
Msg 8117, Level 16, State 1, Line 37 Operand data type varchar is invalid for minus operator.
I've tried casting
(DAY,-@RefreshDays,GETDATE()) as date. Not exactly sure which data type to cast it to as its supposed to be a date.
DECLARE @RefreshDays VARCHAR(20)='2020-10-01' select FORMAT(DATEADD(DAY,-@RefreshDays,GETDATE()),'yyyyMMdd') select @RefreshDays
More from @sqljunkyking