cecilia13
cecilia13

Reputation: 19

DB2 showing 0 instead of decimal place

I am trying to calculate milliseconds into seconds for a field. I was using [field]/1000 and that works as long as the value is greater than 1. Once its under ``1 I get 0. So if the value is 460 I get 0 instead 0.46.

I tried the below:

RUNTIME/1000 as test,
CAST(RUNTIME/1000 as DECIMAL(5,2)) as test2

Upvotes: 0

Views: 464

Answers (1)

Mark Barinstein
Mark Barinstein

Reputation: 12299

Refer to the Expressions article.

Two integer operands

If both operands of an arithmetic operator are integers, the operation is performed in binary and the result is a large integer unless either (or both) operand is a big integer, in which case the result is a big integer. Any remainder of division is lost. The result of an integer arithmetic operation (including negation by means of a unary minus operator) must be within the range of the result type.

Upvotes: 3

Related Questions