# No cents coldfusion

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

x
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.

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

".00" does not exist in 200000.23

Try this function that I found on http://cookbooks.adobe.com/post_No_cents_DollarFormat-16261.html:

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

#MyDollarFormat(someMoney)#

Experts Exchange Solution brought to you by

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

Commented:
The function is the better option. But another shortcut for US dollars is

<cfoutput>#listFirst(dollarFormat(200000.23), ".")#</cfoutput>
Commented:
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") />

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

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

No, I believe they want to remove the zeroes.
Commented:
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", "\$") />

Or

#NumberFormat("55.99", "\$")# - for just an output solution.
Commented:
> #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.