CFLib.org – Common Function Library Project

TrimZero(varToTrim)

Last updated August 26, 2005

author

Praveen Mittal

Version: 2 | Requires: CF6 | Library: StrLib

Description:
Trim traling zeros from a numeric field.

Return Values:
Returns a number.

Example:

<cfoutput>#TrimZero("0.00000")#</cfoutput><br>
<cfoutput>#TrimZero("122.00000")#</cfoutput><br>
<cfoutput>#TrimZero("0.12340000")#</cfoutput><br>
<cfoutput>#TrimZero("0.120042000")#</cfoutput><br>
<cfoutput>#TrimZero("123.0234000")#</cfoutput><br>

Parameters:

Name Description Required
varToTrim Number to trim. Yes

Full UDF Source:

<!---
 Trim traling zeros from a numeric field.
 Version 2 by Raymond Camden
 
 @param varToTrim      Number to trim. (Required)
 @return Returns a number. 
 @author Praveen Mittal (praveen@smeng.com) 
 @version 2, August 26, 2005 
--->
<cffunction name="TrimZero" output="false" returnType="string">
    <cfargument name="varToTrim" type="numeric">
    
    <cfreturn arguments.varToTrim + 0>
</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson