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

Remove zeros from a number 1

Status
Not open for further replies.

infotech2

MIS
Nov 29, 2001
34
US
I have a database that stores some order numbers like this: 2301.000, 2301.001, 2301.002, etc. The .001 means the original service needed follow up. The only way I can find to display this number in Crystal is by formatting the number in this format: 0000.0000 so it shows up like this: 2301.0000, 2301.0010.

I have to come up with a method to count the number of services considered follow up. I'd like to convert all the numbers to this: 2301, 2301.1, 2301.2, etc. Then I could create a formula that counts all of the services that have a decimal, or something like that.

Is there a way to convert the numbers to that format?
 

Give this a try:

whileprintingrecords;
numbervar x := instr(totext({yourfield},"#.###",3),".") - 1;;
stringvar y := totext({yourfield},"#.###",3);

tonumber(left(y,len(y) - x) + replace(right(y,len(y) - x),"0",""))

 
This work as long as you do not get as high as
2300.010 if you do some extra logic will be required.

@service
local numbervar fup:= int(tonumber('2301.001')*1000)- int(tonumber('2301.001'))*1000;

if fup = 0 then totext(int(tonumber('2301.001')),0,"")
else
totext(int(tonumber('2301.001'))+(fup/10), 1,"")

Replace '2301.001' with

totext(yourordernumber,3,"")

Ian

 
Thank you both for the quick response.

Brian - I tried yours and it removed the decimal completely.

Ian - I get "The remaining text does not appear to be part of the formula" for Replace to the last ).

Thanks Again!
 
Holy crap I'm a moron. Ian - That worked great. I just need another cup of coffee.
 
Why not just create a formula like this (if it is true that ANY decimal other than 0 means a followup is required)?

if int({table.number}) = {table.number} then
0 else 1

Insert a sum (NOT a count) on this formula.

-LB
 
lbass - Thanks for the suggestion. I also wanted a way to show the numbers without the zeros so they are more readable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top