Truncate decimals

  • Thread starter Thread starter mbraj via AccessMonster.com
  • Start date Start date
M

mbraj via AccessMonster.com

This is another challenge need solving

i have this number : 56.9796546

I want the number (NOT FORMATTING METHOD) to be 56.97 please note there is no
rounding up or down . How do I do this ?

Access always rounds up i just want to truncate the numbers after the 2
decimal places.
 
mbraj via AccessMonster.com said:
This is another challenge need solving

i have this number : 56.9796546

I want the number (NOT FORMATTING METHOD) to be 56.97 please note there is
no
rounding up or down . How do I do this ?

Int(n *100) / 100

Tom Lake
 
Tom said:
Int(n *100) / 100

Alternatively:

SELECT FIX(-56.9796546 * 100) * 0.01

returns -56.97.

Note the DECIMAL data type by nature exhibits truncation on
INSERT/UPDATE e.g. with a scale of 2 the OP's value will be truncated
as expected e.g.

CREATE TABLE TestDecimals (
dec_col DECIMAL(4, 2) NOT NULL
)
;
INSERT INTO TestDecimals VALUES (-56.9796546)
;
SELECT dec_col
FROM TestDecimals
;

returns -56.97.

Jamie.

--
 
Back
Top