I have a column named 'order_confirmation_date' that is in Datetime2 format and I need it to work with bigint with the below query that uses datediff b/w the column value and getdate().
SELECT
datediff(day, convert(VARCHAR(10),
NULLIF((
CASE WHEN cast(replace(convert(varchar(10),cast(fpo.order_confirmation_date as date)),'-','') as bigint) >= cast([dbo].[fnGetFormatedDate](getdate(), 'YYYYMMDD') AS BIGINT)
THEN fpo.order_confirmation_date
ELSE NULL
END
), 0),112), GETDATE()) * (- 1) AS ordconf_x_days_fromtoday
FROM bidb.fact_purchase_order fpo
Msg 50000, Level 16, State 2, Line 1409 Operand type clash: datetime2 is incompatible with bigint