Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Roundup ?

Status
Not open for further replies.

robcunliffe

Technical User
Mar 22, 2005
22
GB
Does anyone know the function to round up numbers. to the next whole number.

i.e 0.02 roundup to 1

or

123.3 roundup to 124

any help would be appreciated.

many thanks

Robert cunliffe
 
Please post your software version, it DOES matter.

Here's a good whitepaper on the topic:



Here's the blurb (TAKEN FROM TEK-TIPS):

Sometimes in a report, you would like to round a number up if it has any decimal places at all (ie not just 0.5 or over). You can do this with a formula of:
If {number.field} - truncate({number.field}) <> 0 then truncate({number.field})+1 else
{number.field}
The advantage of this method is that you can use it in calculations – otherwise you are simply formatting the display The logic is that is when you truncate a number, you throw away any decimals. Subtract the truncated number from the original number and you can isolate the decimal part of the original number.

If the decimals are 0 then use the original number as it has no decimals. Otherwise add one to the truncated value and you have rounded the number with decimals up to the next integer value.

Thanks to Mike (mbarron) on Tek-Tips for answering this question.

-k
 
If you are using XI, there is a RoundUp function that was introduced to do this, otherwise the method sv posted will have to be used.

~Brian
 
I would have mentioned it as well (I alluded to it with "it DOES matter."), Brian, but when people don't bother to post their software version I tend to get annoyed at their, um haste to post at the expense of facts.

-k
 
Many thanks for your help.

I am using crystal reports 10, i apoligies for not stating this.

This forum is mostuseful and its great thst there are people willing to help others. once again many thanks

Rob Cunliffe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top