Gentlemen, I'm migrating my system from Oracle to SQL Server,
I'm having trouble doing the following operation
SELECT
CASE WHEN (EPL.DAT_VENCIMEN - EPL.DAT_FABRICA) > 0
THEN CAST(((CAST(SYSDATE-EPL.DAT_FABRICA AS INT)) /
(CAST(EPL.DAT_VENCIMEN-EPL.DAT_FABRICA AS INT)) * 100) AS INT)
ELSE 0
END AS PERCENTUAL_P,
epl.*
FROM emp_produto_lotacao EPL
This query returns the values correctly in Oracle. However in SQLServer the values are zeroed. Remember that in SQLServer SYSDATE
must be replaced with GETDATE()