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

very weired situation. round, int, truncate don't work 1

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
CR8.5

I have a string value, say 12345.23. I just want to see 12345, no decimal and digits after it. I use ToNumber function to first convert it to Number and then I have tried using
Round(12345.23,0),
Truncate(12345.23,2) and
Int(12345.23)
functions, but what I get is 12345.00. Why is it happening? Why it is still giving me decimal and two zeros?
Any idea ? thanks
 
You can right click on the field > Format Field > Number and select the type you want.

Kchaudhry
 
This will return the non decimal portion as a string:
[tt]split({Table.Field},".")[1];
[/tt]
This will return it as a number with no decimals, and no thousands separator:
[tt]totext(tonumber({Table.Field}),0,"")
[/tt]
-dave
 
Thanks to you both.
Kchaudry's solution works when we simply round the number from the Windows.
But,here it was not the case. I knew that I had a number if I just wanted to round it, it was very easy as KChaudry said. But I wanted to show number as string on the report and before showing it string, wanted to trim decimal and all digits after decimal.So Dave's solution works best in this situation.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top