Show 2 Decimal places without rounding

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Show 2 Decimal places without rounding

Post by Leesha »

Hi,
I have a query that returns numbers that will go beyond 2 decimal places. I need it to be formatted to currency which I can do. The problem is that it rounds to the next highest decimal and I need it to cut off anything after 2 decimals. For example, 2077.9375 should return $2077.93 not $2077.94. Is this possible and if so how would I format it?

Thanks,
Leesha

StoneChucker
StarLounger
Posts: 80
Joined: 24 Jan 2010, 13:09
Location: Brantford, Ontario, Canada

Re: Show 2 Decimal places without rounding

Post by StoneChucker »

Use the TRUNC function. =TRUNC(<reference>,2)

EDIT: Oops! Didn't realize this was the Access forum. I assumed Excel. Sorry!
Last edited by StoneChucker on 21 Jun 2010, 15:20, edited 1 time in total.

Christopher

User avatar
HansV
Administrator
Posts: 78517
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Show 2 Decimal places without rounding

Post by HansV »

Let's say that the field containing the numbers is called Amount.
Create a calculated column in the query:

Amt: Int(100*[Amount])/100

This column will contain the values truncated to 2 decimal places instead of rounded. Format the column as Currency.
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78517
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Show 2 Decimal places without rounding

Post by HansV »

StoneChucker wrote:Use the TRUNC function. =TRUNC(<reference>,2)
Hi Chris,

TRUNC is an Excel worksheet function, it is not available in Access.
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Show 2 Decimal places without rounding

Post by Leesha »

PERFECT!!!

Thanks,
Leesha

Sgte
2StarLounger
Posts: 164
Joined: 10 Feb 2010, 12:53

Re: Show 2 Decimal places without rounding

Post by Sgte »

Hi Hans,
I have a field in a table that I have designated as a currency format with 2 decimal places. However, indeed with any format I try, rounding still occurs. Very annoying - so how do I stop this please?

User avatar
HansV
Administrator
Posts: 78517
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Show 2 Decimal places without rounding

Post by HansV »

Sorry, I don't understand - how are the data rounded?
Best wishes,
Hans

Sgte
2StarLounger
Posts: 164
Joined: 10 Feb 2010, 12:53

Re: Show 2 Decimal places without rounding

Post by Sgte »

the data in question is 18.83, which rounds to 19.00. I have now changed the format to decimal with Auto decimal places. This seems to have retained the data at 18.83. Still very annoying.

User avatar
HansV
Administrator
Posts: 78517
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Show 2 Decimal places without rounding

Post by HansV »

Strange - if you set the data type to Currency, the default format should be Currency and decimal places should be set to Auto. The field should then use your Windows setting for currency:
x83.png
x84.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans