2
Gentlemen, I am migrating my Oracle system to SQL Server,
I’m having trouble making 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 reset. Remember that in Sqlserver the SYSDATE
should be replaced by GETDATE()
the conversion to int may be returning a value less than zero, tried to convert to float using
convert(float, SYSDATE-EPL.DAT_FABRICA)
to make the calculation?– Ricardo Pontual
I tried to use Convert too, I think it should work too, the tip to change to float was what helped me. Thanks
– Ivan Mzl