How do I round to the nearest 0.5

Posted on 2004-11-10
Medium Priority
Last Modified: 2010-05-18
I need to round this formula up to the nearest 0.5

{pcrsadd.lec_mins} / 60 / 18

The answer comes out at 0.412, I can round it to 0.4 but it needs to be 0.5

Thank you for your help
Question by:Matt_Johnston35
  • 2
  • 2
LVL 13

Expert Comment

ID: 12550432
that's the best i can come up wtih. i have only tested it with a few values (ie no negatives), so be careful ;-)

numbervar mynumber := 8.9;
numbervar myremainder := Remainder(mynumber, 0.5);
if ( myremainder < .25) then
  mynumber := mynumber - myremainder
  mynumber := mynumber + 0.5 - myremainder

just pass whaterver value or database field you need into the mynumber variable.
LVL 101

Accepted Solution

mlmcc earned 1000 total points
ID: 12551170
Here is a link to another formula


Formula when changed to round to the .5 is
Round ( {database.field} / .5 , 0 ) * .5

LVL 13

Expert Comment

ID: 12557992
mlmcc's approach seems far better!
LVL 101

Expert Comment

ID: 12589799
Glad i could help


Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 10 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question