We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Converting a File Date to a recognised ColdFusion format

Medium Priority
Last Modified: 2013-12-24
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?


Watch Question

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 & filelist.name & "\")#</CFIF>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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...


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.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.