Link to home
Create AccountLog in
Avatar of MichaelEvangelista
MichaelEvangelista

asked on

QuerySetCell changes numeric value

I have a query that is a Q of Q from a cfdirectory, getting a list of image files

<!--- Query the Query --->
<cfquery name="application.listimages" dbtype="query">
SELECT NAME, DATELASTMODIFIED, SIZE as filesize
FROM application.imagedir
ORDER by NAME
</cfquery>

Works fine.

What I want to do, before I output my xml for the gallery i am using, is to format the filesize value in the query.

Using 'querySetCell()' , I am having results I cannot explain.

<cfloop query="application.listImages">
<cfset sizevaltemp = querySetCell(application.listImages, 'filesize', '#numberFormat(filesize, ',')#', #rowID#)>
</cfloop>

If I do a cfdump for "numberformat(filesize, ',')", I get the correct, formatted number.
But if I dump out the query after this point, the number inserted is a different, negative value.

Is there something strange about querysetcell() and numeric values?
How can I replace the value of this existing query object row by row in my cfloop?






Avatar of rob_lorentz
rob_lorentz

what about doing the formatting as part of the sql select?

SELECT NAME, DATELASTMODIFIED, SIZE as filesize,
    substring(convert(varchar(40), cast(size as money), 1), 0, len(convert(varchar(40), cast(sizeas money), 1))-2) as displayFileSize
FROM application.imagedir
ORDER by NAME
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of MichaelEvangelista

ASKER

@Zvonko: Perfect, thank you. Adding the '' blank field to the query, then copying from one column to the other, is perfect.
@rob: looks slick, but didn't try it.  Maybe it will help somebody else, thanks for posting.