equivilant to trunc function in access

  • Thread starter Thread starter Grd
  • Start date Start date
G

Grd

Hi there,

I used the round function but it rounded my numbers - I really just want to
cut of the decimals at the 2 decimal. I read about the trunc function on the
internet however it only works in excel and I need to do this in a query.

Any help would be great as my numbers are off by a little.

Thanks

Suzanne
 
int(100*x)/100

should do.


? int(100*1.23456)/100, int(-1.23456*100)/100, fix(-1.23456*100)/100
1.23 -1.24 -1.23



Vanderghast, Access MVP
 
Grd said:
I used the round function but it rounded my numbers - I really just want to
cut of the decimals at the 2 decimal. I read about the trunc function on the
internet however it only works in excel and I need to do this in a query.


Try using:

Int(thefield * 100) / 100
 
tx v much


Michel Walsh said:
int(100*x)/100

should do.


? int(100*1.23456)/100, int(-1.23456*100)/100, fix(-1.23456*100)/100
1.23 -1.24 -1.23



Vanderghast, Access MVP
 
Michel makes a good point. If any of your numbers might be
negative, you probably want to use Fix instead of Int. If
all your numbers are guaranteed to be non-negative, then
both functions will yield the same result.
 
Thanks guys, you are geniuses. I did not expect it to be so easy.

I want an upper limit of 20, so my code basically went from this

=IF(TRUNC(P2/10,0)>20,20,TRUNC(P2/10,0))

to this:

IndAge35_45: IIf(Int([Age35_45]/10)>20,20,Int([Age35_45]/10))

Eric
http://www.infomoving.com
 
Back
Top