I am fairly new to Coldfusion. I am trying to run a cfloop where I go through the months to date from a PostgreSQL table, and add the integer values in the cells, during the loop. The cells are filled out for the entire year, so I don't want all of them, just January to now. My code looks like this, but I get a "The value goals.data_1 cannot be converted to a number." error when I run it.
<cfset ytdGoal = 0>
<cfset mymonth = month(now())>
<cfloop from="1" to="#mymonth#" index="myindex">
<cfset running = ("goals.data_"&myindex)>
<cfset ytdGoal = ytdGoal + #running#>
</cfloop>
If I do an evaluate, I get a count of the months just fine. The PostgreSQL columns are set up for integer values. Any help is greatly appreciated.
cfloop, I'd do it in SQL then output that. - ShawnytdGoalis an integer, butrunningis literally"goals.data_1", so it is failing. - Shawngoalsquery you're using? Is the data flattened out during the query or is it stored that way? - Shawn