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!

Help on Crystal Report Function,Converting number into text 2

Status
Not open for further replies.
Nov 5, 2004
27
0
0
PH
Hi,
I would like to know if there are functions in crystal report that i can used in converting numbers into words.

Ex. 125.75 will be converted into words:
one hundred twenty five and seventy five cents

Is it possible?Thanks.
 
This is taken from the Crystal help file:

ToWords(12345)

Returns twelve thousand three hundred forty-five and xx/100.

ToWords(12345.6749,2)

Returns twelve thousand three hundred forty-five and 67/100.

Hope it helps.

Rene'
 
The ToWords command will automatically turn a whole number into words. Say ToWords({Your.Amount}). For whole numbers this is OK: 4,304 becomes four thousand three hundred four.

Decimals - normally used for currency - are a different matter . ToWords({Your.Amount},2) for 4304.34 will give you four thousand three hundred four and 34/100. For zero pence it would be and xx/100. (This is Crystal 8.5: later versions may be better.)

You can get a much neater look using something like:
Code:
if Truncate({Your.Amount}) = {Your.Amount}
then
ToWords({Your.Amount}) & " dollars exactly" 
else
ToWords({Your.Amount}) & " dollars , "  &
Towords(Tonumber(Right(totext({Your.Amount}, 2), 2))) & " cents"


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Try:

ToWords(truncate({Table.Amount},0),0)+" dollars and "+
ToWords(Val(Right(totext({Table.Amount}),2)),0)+" cents"

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top