Skip to content

Instantly share code, notes, and snippets.

@kukielp

kukielp/demo.cfm

Created Nov 19, 2020
Embed
What would you like to do?
<cfscript>
loopLength = 10
qry = queryNew("id,dstart_time", "integer,Timestamp");
for(i=1; i<loopLength; i++){
tmpDate = dateAdd("d",-i,now());
queryAddRow(qry);
querySetCell(qry, "id", i);
querySetCell(qry, "dstart_time", tmpDate);
}
writeOutput("Query new:")
writeDump(qry);
</cfscript>
<cfset strt = {} />
<cfloop query="qry">
<cfset strt[qry.id] = qry.dstart_time />
</cfloop>
<cfdump var="#strt#" />
<cfset sortedQry = structSort(strt,"numeric","asc") />
<cfdump var="#sortedQry#" />
<cfloop from=1 to="#arrayLen(sortedQry)#" index=i >
<cfset item = sortedQry[i] />
<cfoutput>#strt[item]#</cfoutput>
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment