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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding to the nearest .50 cents

Status
Not open for further replies.

goodkarma

Programmer
Aug 28, 2003
17
US
I have a Crystal Report (version 8.5) that is using the following formula.
if {L_NAE_PRICE_LIST.Formula} = 'Y' then x := If Truncate({L_NAE_PRICE_LIST.Cost}*1.485,2) <> ({L_NAE_PRICE_LIST.Cost}*1.485) then
Truncate({L_NAE_PRICE_LIST.Cost}*1.485,2) + 0.50
else
Truncate({L_NAE_PRICE_LIST.Cost}*1.485,2);
I am using Peoplesoft query to drive the report... What I am trying to do with the above formula is to round the cost to the nearest .50 cents.. This formula is not working... I have an Oracle database function called fiftycent that does what I want this formula to do but I don't know how to incorporate the database function into formula or if that is even needed here. I hope I am explaining this well enough... Thanks in advance for any help!!!
Karma
 
if val(right(totext({@yourformula},3,""),3)) in 250 to 749 then truncate({@yourformula},0) + .5 else
if val(right(totext({@yourformula},3,""),3)) in 000 to 249 then truncate({@yourformula},0) else
if val(right(totext({@yourformula},3,""),3)) in 750 to 999 then truncate({@yourformula},0) + 1

I wasn't sure why you were multiplying by 1.485. If that is a calculation for some other reason, e.g., reflecting a markup, then the above formula assumes that {@yourformula} is:
{L_NAE_PRICE_LIST.Cost}*1.485

-LB
 
This Formula is close to working but I need it to round UP to the nearest .50 cents... For example
328.50 on report with current formula
328.52 calculator
329 (this is what I want it to be on report)

289 on report with current formula
289.05 calculator
289.50 (this is what I want it to be on report)

414.50 on report with current formula
414.73 calculator
415 (this is what I want it to be on report)
Any ideas as to how to do this??? I probably didn't explain myself very well the first time...
Thanks,
Karma
 
To always round up to the next 50 cents, try:

if val(right(totext({@yourformula},3,""),3)) = 000 then
truncate({@yourformula},0) else
if val(right(totext({@yourformula},3,""),3)) in 001 to 500 then
truncate({@yourformula},0) + .5 else
if val(right(totext({@yourformula},3,""),3)) in 501 to 999 then
truncate({@yourformula},0) + 1

-LB
 
Try this formula:

-int(-({put.your.number.here}/.5))*.5

Mike
 
lbass,
Thank you!!! The formula now works EXACTLY as it should!!! I really appreciate the help..
Thanks again,
Karma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top