equivilant to trunc function in access

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
 
M

Michel Walsh

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
 
M

Marshall Barton

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
 
G

Grd

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
 
M

Marshall Barton

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.
 
Joined
Mar 19, 2009
Messages
1
Reaction score
0
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
 

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