Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to sort a cddirectory list of folders

Status
Not open for further replies.

costarica1

Programmer
Mar 22, 2004
9
CR
I have a program I wrote that copies some images and a text report to a folder each day to archive them. Now I have a list that spans since last may of each days report. Its starting to be a lot of entries and time to organize it better. An example of the directories is posted here:

So I list it with this:
<cfdirectory directory="#archives_location#" action="list" name="archives" sort="datelastmodified">

Then display with this:

<cfset counter = 0>
<cfoutput query="archives"><!--- Outputs the list of folders in the archives area. --->
<cfif archives.name neq "Copy-this">
<cfif counter eq 20>
</td>
</cfif>
<a href="../daily_archive/#archives.name#/">#archives.name#</a><br>
<cfset counter = counter + 1>
<cfif counter eq 20>
<cfset counter = 0>
<td>
</cfif>
</cfif>
</cfoutput>

Basically, I just need help sorting the dates ( the "datelastmodified" sort in the Cfdir tag isn't working how I would have hoped ) and also how I would query that list from a cfquery tag. My friend suggested this, but it threw me an error.
<cfdirectory directory="#archives_location#" action="list" name="archives" sort="datelastmodified">
<cfquery name="dircon" dbtype="query">
select *,
left(name,2) as mVal,
right(left(name,5),2) as dVal,
right(name,2) as yval
from archives
order by yval asc, mval desc, dval desc
</cfquery>
 
if datelastmodified is not working properly then one thing i would suggest is chang the name of your dir's

to yyyy_mm_dd then sort by name

------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
i agree, using functions in a QoQ has always been a little buggy from my experiences. i also think it would be easier to change your dir names.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top