Truncate decimals

  • Thread starter mbraj via AccessMonster.com
  • 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.
 
T

Tom Lake

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
 
J

Jamie Collins

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.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top