Truncate a result

R

Rossy

Is it possible to truncate the number that is the result of a query to 2
decimals??
(it's a %)
Thanks
 
R

Rossy

I've got this in the structure of a query
Percentuale: [Acquisto]/[Netto]*100

Acquisto and Netto are 2 values of the table
I need Percentuale to be round to two decimals
 
W

Warrio

for that, you can do:
SELECT Fomat([Acquisto]/[Netto]*100),'0.00') AS Percentuale FROM YourTable
or
SELECT Round((1/3*100),2) AS Percentuale FROM Master

the only problem you can have is that you might have the field [Netto] equal
to Null or 0
so you'll have an error because you'll have a division by 0!

for that you can use the following condition:

Percentuale: iif(IsNull([Netto]) or [Netto]=0,'NA',
Fomat([Acquisto]/[Netto]*100),'0.00'))







Rossy said:
I've got this in the structure of a query
Percentuale: [Acquisto]/[Netto]*100

Acquisto and Netto are 2 values of the table
I need Percentuale to be round to two decimals

Warrio said:
Hi!
You can use the functions Round(number, nbDec) or Format(Number,"0.00")


"Rossy" <[email protected]> a écrit dans le message de
[email protected]...
 
V

Van T. Dinh

Do you simply want to display the result as percentage with 2 decimal places
or do you need the rounded value for further calculations?

For the first case, you can simply set the Format of the Field (column in
the Query grid) to "Percent". For the later, you can use the Round()
function.
 
Top