Round up

HV_L

Registered User.
Local time
Today, 08:49
Joined
Dec 23, 2009
Messages
53
Hi,

I have this query in VBA:
Code:
SELECT CInt(Count([id])/2+1) AS Aantal
  FROM Wedstrijd
  WHERE (((Year([Datum]))=Year(Now())) AND ((Wedstrijd.Datum)<=Now()));
Now the problem is that in case the outcome of Count([id])/2 is 6,5 Access seems to round this up to 7 +1 makes the final outcome 8

How can I play with rounding upwards and/or downwards ?
How should I write this to get 7 as final outcome ?

Thanks.
 
The issue is that if you have a .5 it automatically rounds up.. you would have to change this to round down


Question is, is this always going to be the case? Are you always going to want to round down?
 
Hi Rainman,

Yes, I always want to round down to the whole number, so no decimals.
Can you tell me how this code would look like?
Thanks
 
The Int function returns a result without decimals.

To round up use Int({expression}+0.99)

This will round up 1.01 but not 1.009
Include as many decimal places as you need to control the handling of small decimal values.

However check the result is what you want if using negative numbers as an input.
Int() and Fix() treat negatively numbers differently.
 
Last edited:
Hi Rainman,

Yes, I always want to round down to the whole number, so no decimals.
Can you tell me how this code would look like?
Thanks

In that case take a look at Int() Function in preference to the CInt Function.

Int() returns the integer portion of the number rather than rounding to the nearest integer as CInt() does.
 

Users who are viewing this thread

Back
Top Bottom