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

Need formula to split decimal and whole number

Status
Not open for further replies.

meryls

Technical User
Nov 20, 2003
62
0
0
US
I am getting a numeric data element that represents a quantity and a count.

Example: 550.2 is really a quantity of 550 and a count of 2
3300.12 is really a quantity of 3300 and a count of 12.

I need a formula that separates the quantity from the count and puts them into different variables.

Thanks for your help!
Meryl
 
Is this really a number? Or is it a numeric string? You can use formulas like this:

//{@qty}:
stringvar x := totext({table.number},4,"");//change 4 to maximum number of decimals
stringvar array y := split(x,".");
if ubound(y) > 1 then
val(y[1])

//{@count}:
stringvar x := totext({table.number},4,"");
stringvar array y := split(x,".");
if ubound(y) > 1 then
val(y[2])

If the field is already a string, remove the totext() function.

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top