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

Split 10 Digit number output to two seperate outputs 2

Status
Not open for further replies.

CR85user

Technical User
Jan 18, 2005
522
GB
Using Crystal Reports 8.5

Relatively new to Crystal Reports so please tolerate my ignorance :)

Am trying to convert the 10 digit number output of a field to two seperate numeric outputs.

Current output: 1,234,567,891.00

Would like to take from this the following two sections:

1) 1st two digits of output

2) Last six digits of output excluding decimal points.

In both cases would like output as whole number without comma seperation.. i.e.

Output 1)

12

Output 2)

567891

Have experimented with formatting the field but have then been unable to limit to just certain parts of number output,
Have also tried various methods of totext / tonumber after searching the forums, but to no avail.

Even tried in desperation to right justify and resize/allow clipping on field, however although viewed output was ok while printing it re-adjusted the output.

The output number is not going to be used to calculate any other formula or integer.

Thanks in advance for any help.

J
 
Try this:

//@FirstTwoDigits
Left(ToText({Table.Field},0,""), 2)

//@LastSixDigits
Right(ToText({Table.Field},0,""),6)

-dave
 
You might still have the problem with commas and decimals...

Try these formulas to segment your numbers into two strings that exclude commas, decimals, and trailing zeroes.

//@FirstTwoDigits
Left (Replace ((ToText ({SplitNumbers_txt.NUMBER})),"," ,"" ),2)

//@LastSixDigits
Right (Replace (Replace ((ToText ({SplitNumbers_txt.NUMBER})),"," ,"" ),".00" ,"" ),6)
 
Using the ToText function with Number fields takes 4 optional parameters:

ToText([field], [# of decimals], [thousands separator], [decimal separator])

So, using the ToText function with the right arguments will assure the 'removal' of any commas.

-dave
 
Thanks both for the speedy replies, Tried both suggestions for testing purposes and both worked very well.

Thanks also Vidru for the explanation of those parameters, has helped my understanding of the above a great deal. :)

Is there a centralised KnowledgeBase for various function arguments for crystal?

J

 
The help files are a great resource. If you look up the ToText function there, you'll see how the arguments can be different depending on the datatype of the field.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top