Skip to main content
Known Participant
December 13, 2015
Answered

Having Difficulty in Preventing CF from Rounding Money Figures

  • December 13, 2015
  • 2 replies
  • 301 views

I'm using CF7 (it might even be CF6.5).  My hosting administrator is vague; it's rented space. Because of this dilemma, many solutions are not pertinent, because the version is antiquated.  I cannot help this.


For now, though, my CF code is displaying all my pennies as whole dollars.  I have:


#dollarformat(rpr_srvc_hst_amt_)#


My CSS aligns the values to the right, but I'm not sure if it's affecting the $59.99 becoming $60.00 Also, I'd prefer to eliminate the dollar sign, and just have 59.99 and other similar values (i.e. 49.99, 19.99).  This may entail another function besides dollarFormat.  I tried NumberFormat, but it rounds off also.


Please help.

    This topic has been closed for replies.
    Correct answer BKBK

    Use decimalFormat or numberFormat plus mask, for example,

    <cfoutput>decimalFormat: #decimalFormat(49.99)#<br>

    numberFormat: #numberFormat(59.99,"__.__")#</cfoutput>

    2 replies

    EwokStudAuthor
    Known Participant
    December 13, 2015

    Apparently, the MS Access field, having been set to "Currency" as a datatype, will be displayed in CF, as a "Single" subdatatype (one of the MS Access Number Datatypes).  #NumberFormat(field,____.__')# will not display the pennies, however, DecimalFormat will display the pennies, but no dollar sign, even if the Access database field is set to Currency.  Preferring no dollar sign anyway, I like this.  I've not tried the mask using the dollar sign; I've just tried it without the dollar sign,  It's easier for potential customers to view the costs without the dollar sign, because they already know it will be in dollars.  This is a marketing method, used by some companies, to psychologically "simplify" the values/costs.  The dollar sign is thought to "appear to be more expensive" psychologically, adding "clutter."  My thank you for the DecimalFormat() function solution.

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    December 13, 2015

    Use decimalFormat or numberFormat plus mask, for example,

    <cfoutput>decimalFormat: #decimalFormat(49.99)#<br>

    numberFormat: #numberFormat(59.99,"__.__")#</cfoutput>