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

Rounding Numbers/ Forcing Integers

Status
Not open for further replies.

tomk01

ISP
Oct 18, 2004
69
US
Hello all,

I need to force a number to round and then display the integer.

right now the number looks like this:

Ident Hours
1 40
2 40.25
3 40.15
4 40.56

I need the number to look like this

Ident Hours
1 40
2 40
3 40
4 41

is there an easy way to do this?

I am using Crystal V. 8.5. I will be incorperating this number into this code
Code:
numbervar reqlength := 4;
numbervar currlength := if not isnull({mytable.myfield}) then length(totext({mytable.myfield}*1000,"0000"));
stringvar YTDHrs := if not isnull({mytable.myfield}) then totext({mytable.myfield}*1000,"0000");

if  currlength > reqlength then
    YTDHrs := YTDHrs[1 to reqlength]
else
    YTDHrs := replicatestring("0", (reqlength - currlength)) + YTDHrs;
YTDHrs;

this formula forces the number to look like this:

ident Hours
1 0040
2 4025
3 4015
4 4056

end results need to be:

ident Hours
1 0040
2 0040
3 0040
4 0041
 
You don't need a formula at all, place the field, right click it and select format field and set the rounding precision.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top