CDML and \$ amount format.

This topic is 7353 days old. Please don't post here. Open a new topic instead.

Recommended Posts

In my database I have some dollar amount fields (as an example they are formated like \$500.56).

There is a field calculation that adds them all up to a total. It is also formated like \$2,125.63

When I show the dollar amount fields and the total amount field in cdml on a web page I get something like 2125.626875

I tried doing numbertotext calculation fields, and adding in a \$ sign for good measure. Then linking the CDML to the numbertotext fields...

Now I get \$2125.626875

Solves the dollar sign, but can't figure out how to get the decimal figures to show up correctly as \$2,125.63 on the web page.

LR

[ April 08, 2002, 10:58 AM: Message edited by: Larry Ross ]

Share on other sites

Hi there. I had the same problem. I solved it by using the round function in the FM program and have it round to two decimal places after the whole number....like this:

round(field_name,2)

Share on other sites

oh I forgot...to get the round to work, I had to create a whole new field to store the round calculation. Sorry about that.

Share on other sites

Try this calc. Rename "DollarAmt" in this calc to the name of your field. The result of this calc is text.

"\$"&NumToText(Int(DollarAmt))&Left(Round(NumToText(Mod(DollarAmt , 1 )) , 2 ),3)

Hope this helps

Share on other sites

"\$"&NumToText(Int(DollarAmt))&Left(Round(NumToText(Mod(DollarAmt , 1 )) , 2 ),3)

If the field DollarAmt contained \$500.00, this calculation returned the result \$5000

If the field DollarAmt contained \$500.37, this calculation returned the result \$500.37

So this calc does not work if it is a .00 amount?

LR

[ April 08, 2002, 12:06 PM: Message edited by: Larry Ross ]

Share on other sites

round(field_name,2)

This calculation changed the amount of \$1,500.37 into \$1500. 37

Changed the amount of \$1,500.00 into \$1500

Changed the amount of \$1,500.30 into \$1500. 3.

Is there a way to have it add in the , between the 1 and the 5?

If a original number ends in .00 it drops off the .00?

If a number ends for example in .30 it drops off the 0 thus making a number look like 1500.3 this looks a bit odd.

LR

[ April 08, 2002, 12:34 PM: Message edited by: Larry Ross ]

Share on other sites

Larry, I realized after I posted the calc that it would not return the correct result when the DollarAmt field contained .00

Look at this thread Prices to text , it should give you some insight into how to accomplish what you want.

Share on other sites

Thanks so much for all the suggestions. I tool a look at the thread. Here is the one that worked.

"\$" & Left(NumToText(FieldName + .001), Length(NumToText(FieldName + .001)) - 1)

It still never ceases to amaze me on how many different ways in FileMaker there are to accomplish the same thing.

LR

[ April 08, 2002, 08:07 PM: Message edited by: Larry Ross ]

Share on other sites

This topic is 7353 days old. Please don't post here. Open a new topic instead.

Create an account

Register a new account