This content has been marked as final. Show 6 replies
Originally posted by: HandersonVA
When I save a minus value, the output comes as (500.00). I think the parentheses are default for the minus value in cf. How can I display –500.00 instead of (500.00)? I looked at the numberformat function, but could not find the mask for it.
Here is how you would do it in oracle. Once you have the gist of it you can see if your own db supports it. by the way, || is oracle's concatonation operator.
when numfield >= 0 then to_char(numfield)
else '-' || to_char(numfield * -1) end displaynumfield
Saving it where, and displaying it how?
<CFIF foo LT 0>-</CFIF>#NumberFormat(Abs(foo), "999,999,999.99")#
I think that can be one of the solutions.
the first time when I insert a minus value, it goes through w/o any problems, but when I update the minus value, i got an error message. so before I use ur select stmt, I need to have a conditional stmt to find a parenthesis to check if the value that I pass to the database is negative or positive. It would be nice if i can find any cf function to display a minus sign instead of a parentheses, "( )" for any minus values.
what i did on this issue before saving into database,
<cfif find("(", form.myprice)>
<cfset form.myprice = ReReplace(form.myprice, ",|\$|\(|\)", "", "ALL")>
<cfset form.myprice = "-" & form.myprice>
<cfset form.myprice = ReReplace(form.myprice, ",|\$", "", "ALL")>
but I wonder if there are other solutions. thanks again.
according to MX7 help docs, if you use
it should place a minus sign at the beginning if negative and a blank space if it is positive.
this example is formatting for 6 digits with a thousands separator, but you could use any formatting mask
I missed the second part of the numberformat function which is minus sign before negative number. thank you SafarTech and others.