Brian Coughter
asked on
Number format: Left pad and remove decimal
I have a dollar amount: 128.56
I need to make it into a 6 byte field, left padded with zeros and the decimal removed (decimal implied) for a delimited flat file.
Taget format: 012856
I need to make it into a 6 byte field, left padded with zeros and the decimal removed (decimal implied) for a delimited flat file.
Taget format: 012856
ASKER
Great but one question...
I was using this:
#NumberFormat(MyNumber, 9999.99)#
If a value (MyNumber) was null, it would get 0.00 automatically. How can I write your solution so that remains true?
Otherwise, I get an error on null values saying: "" Cannot be converted to a number.
I don't want to hard code a bunch of <cfif's in my code.
I was using this:
#NumberFormat(MyNumber, 9999.99)#
If a value (MyNumber) was null, it would get 0.00 automatically. How can I write your solution so that remains true?
Otherwise, I get an error on null values saying: "" Cannot be converted to a number.
I don't want to hard code a bunch of <cfif's in my code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would just add a VAL() function, which translates to 0 for nulls.
#NumberFormat(VAL(MyNumber )*100, 000000)#
#NumberFormat(VAL(MyNumber
<CFOUTPUT>#NumberFormat(My
HTH,
-Dain