No cents coldfusion

Why is this not converting the number to not having cents?
<cfoutput>#replace(dollarFormat(200000.23), ".00", "")#</cfoutput>

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Your example is looking for a matching string ".00".

".00" does not exist in 200000.23

Try this function that I found on

        function MyDollarFormat(money_string){
            money_string = DollarFormat(money_string);
            money_string = rereplaceNoCase(money_string, '\.\d{2}', '');


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The function is the better option. But another shortcut for US dollars is

<cfoutput>#listFirst(dollarFormat(200000.23), ".")#</cfoutput>
If you want to maintain the zeros after the decimal, you can do something like this.

<cfset num = NumberFormat("55.99", ".") />
<cfset num = NumberFormat(num, "$.00") />

Somewhat messier than a one line solution, but it works. Remove the dollar sign if not necessary.

Or you can do this: <cfset num = Numberformat(NumberFormat("55.99", "."), "$.00") />

A little less readable though.
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

This will just get rid of the zeros and decimal, only function needed:

<cfset num = NumberFormat("55.99", "$") />
> If you want to maintain the zeros

   No, I believe they want to remove the zeroes.
Ok, I wasn't sure if they wanted to zero out the cents or just remove them.

So this will work fine then

<cfset num = NumberFormat("55.99", "$") />


#NumberFormat("55.99", "$")# - for just an output solution.
> #NumberFormat("55.99", "$")#

Neat. I don't know that I've ever that particular mask. But bear in mind it will round the value. So the result will be "$56", rather than "$55".  If that's acceptable, go with that one. Otherwise, use one of the previous suggestions.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.