• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Display Amount in Cents

Guest
Jun 04, 2007 Jun 04, 2007

Copy link to clipboard

Copied

Can someone please point me in the right direction for display an amount in cents?
eg: "$100.95" is displayed as "10095"
TOPICS
Advanced techniques

Views

369

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jun 05, 2007 Jun 05, 2007
Could there be some commas in there, perhaps? Why not use regular expressions to remove everything but digits and the decimal and then multiply everything by 100:

#reReplace(myAmount, "[^0-9.]", "", "all")*100#

Votes

Translate

Translate
Guest
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

NumberFormat(Mid(myAmount, 2, 999), "999999999")

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

Could there be some commas in there, perhaps? Why not use regular expressions to remove everything but digits and the decimal and then multiply everything by 100:

#reReplace(myAmount, "[^0-9.]", "", "all")*100#

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

LATEST
xXSeanx wrote:
> Can someone please point me in the right direction for display an amount in cents?
> eg: "$100.95" is displayed as "10095"

<cfscript>
dollars="$100.95";
setLocale("en_US"); // just in case
//currency symbols, commas, decimal points, etc handled per locale
cents=lsParseCurrency(dollars)*100;
writeoutput("#dollars# = #cents# cents");
</cfscript>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation