Rounding function

B

boz

Hello all, I have a query that does a calculation of 15 min increments which
are called units such as: 1 unit=15, 2 units=30, 3 units=45 mins well if the
service is not a full 15 minute increment we can not round up such
as:20min=1.33 units because its not a full 30 minutes to equal 2 units. How
would I put a function in the criteria to round down to 1 if its not the full
15 minute increment?
 
M

Michel Walsh

use Int( ).

As example:

INT( DateDiff("n", date_time1, date_time2) / 15 )


Vanderghast, Access MVP
 
B

boz

THANKS SO MUCH! NOT SURE WHAT THIS FUNCTION MEANS BUT IT WORKS AND i WILL
LOOK INTO TO IT FOR MY OWN UNDERSTANDING!!!!!!!!!
 
M

Michel Walsh

It just drops the decimal part of a floating point number.


? int( 1.01), int(1.999), int( -1.05), fix(-1.05)
1 1 -2 -1



and by 'dropping', it means taking the first integer smaller or equal to the
argument. For negative number, -2 is smaller than -1.05 which is itself
smaller than -1, so

int(-1.05) returns -2.


You can use fix( ), instead of int( ), for negative numbers, if 'dropping'
the decimal part is more like fix that like int, in your application.



Vanderghast, Access MVP
 

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