Converting a File Date to a recognised ColdFusion format

I need to be able to allow a user to enter a date into a form, and on processing the form I need to open a file which has a last modified date which is the same as "form.MyDate".  I have tried using CFDirectory and reading Name.DateLastModified, but I get the following error:

The value "Wednesday, 4 January 2006 12:42:48 PM NZDT" could not be converted to a date.  Is there an easy way of converting that value into a dd/mm/yyyy value?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you provide your actual search format...
I've done this without a problem... (on mx6.1 and 7 in a Windows box...)

<CFSET mydirectory = getDirectoryFromPath(getCurrentTemplatePath())>
<CFSET yesterday = dateadd('h',-24,now())>
<table border>
<th>Name<th>Size<th>Type<th>Date Last Modified<th>Age

<cffunction name="walkDir" access="Private" output="Yes">
 <cfargument name="DirPath" type="string" required="Yes">
 <cfdirectory action="list" directory="#DirPath#"
             name="filelist" sort="DateLastModified DESC">
<CFOUTPUT query="filelist">
<CFIF yesterday LTE datelastmodified>NEW<cfelse>OLD</cfif>
<CFIF filelist.type EQ "Dir">#walkDir(DirPath & & "\")#</CFIF>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jdthedjAuthor Commented:
Thanks for the reply RCorfman

Here is my code (CF 6.1)

<CFSET MyDate = CreateODBCDate(form.WEnded)>

<CFDIRECTORY DIRECTORY="#Session.MTSDir#\#form.Branch#" NAME="GetMTS">


<CFIF DateAdd("d",-2,#GetMTS.DateLastModified#) EQ #MyDate#>


etc etc

Your code works, but I cannot see why mine doesn't.  What am I doing wrong?

I must have had a lapse in my email. I didn't see your post on 3/23. I assume you got it figured out. Sorry for not helping further.  I suspect the problem was the EQ #MyDate# instead of a range... like GTE LTE, or both with two dates to check a range...
jdthedjAuthor Commented:
I cheated in the end and parsed the long date as shown in my question.  I think you are correct about the EQ because I still had trouble within the query from the directory and i had to use more than one cfif to get it sorted.

Thanks for your help.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.