Reputation: 69
I'm trying to use NumberFormat
, on an integer, in order to pad it with leading zeroes. Unfortunately, NumberFormat
seems to have no affect on the integer. Any advice would be appreciated.
<cffunction name="myFunction" access="remote" returntype="numeric">
<cfargument name="myId" type="numeric" required="yes" />
<cfquery name="myQuery">
SELECT COUNT(fileid) AS itemCount FROM files
WHERE directory = '#myId#'
</cfquery>
<cfset newId = numberFormat( myQuery.itemCount, '0000000' )>
<cfreturn newId />
</cffunction>
Upvotes: 1
Views: 340
Reputation: 1539
Change your return type to a string. I'm pretty sure numeric will truncate leading zeros. Also, as a good practice, addoutput="false"
to all your <cfcomponent>
and <cffunction>
tags.
Upvotes: 11