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

Translating Sum of $ amount to words

Status
Not open for further replies.

LTillner

MIS
Apr 23, 2002
96
US
I need a Sum of a field to read out in Text for example:

$11,522,339. would read as:

Eleven Million, Five Hundred Twenty Two Thousand, Three Hundred Thirty Nine Dollars.

How can I accomplish this?

Thanks,
Lynette
 
There is a ToWords() function in the Strings function folder of the Formula Editor. You can also look up the function in the help menu to get more specifics on the use of this function. But this should give you the output you are seeking.

hope this helps.

MRudolph
 
There is a funciton called ToWords that deos this for you.

Code:
Prpoercase(ToWords(11522339)) & " Dollars"
returns
"Eleven Million Five Hundred Twenty Two Thousand Three Hundred Thirty Nine Dollars"

Keep in mind, if you are not using Version 9 or 10, the propercase function will not be available. If that is the case, you will only have the first word in the sentence converted to have a upercase first letter. Also, there will be no commas throughout the returned words. A more creative solution would have to be thought up for that.

~Brian
 
When I use towords(), it returns a fraction at the end: "and xx/100". To remove this, create the following formula {@towords}:

left(towords({table.money}),instrrev(towords({table.money}),"and")-1) +"Dollars"

Then, if you want leading caps, you can use the following formula:

whileprintingrecords;
stringvar array x;
redim preserve x[ubound(x)+1];
numbervar counter := 0;
stringvar result := "";

x := split({@towords}," ");
for counter := 1 to ubound(x) do(
result := result + ucase(left(x[counter],1))+
mid(x[counter],2) + " ");
result;

This doesn't add in commas, but then I don't believe the commas are technically necessary--but maybe that's a matter of personal preference.

-LB
 
Thanks, I will try this in the morning. Actually I want ALL caps and commas after the Millionand Thousands
 
If you put the "towords(value)" in one formula field, say called @wordvalue, you can then use it as input for a Replace(@wordvalue, "Million", "MILLION") etc. You can also nest the commands, as lbass showed

Madawc Williams (East Anglia)
 
What do you mean "All Caps"? My formula (let's call it {@caps} would give you:

Eleven Million Five Hundred Twenty-two Thousand, Three Hundred Thirty-nine Dollars.

Hyphenated words, as are twenty-two and thirty-nine, technically should not have caps for the word after the hyphen. If you really want the commas, then you could do something like:

replace(replace({@caps},"Million ","Million, "),"Thousand ","Thousand, ")

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top