Link to home
Start Free TrialLog in
Avatar of APS NZ
APS NZFlag for New Zealand

asked on

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?

TIA

John
ASKER CERTIFIED SOLUTION
Avatar of RCorfman
RCorfman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of APS NZ

ASKER

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

<CFOUTPUT QUERY="GetMTS">

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

<CFFILE ACTION="Read"
    FILE="#Session.MTSDir#\#form.Branch#\#GetMTS.Name#"
    VARIABLE=MyFile>

etc etc

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

Avatar of RCorfman
RCorfman

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...
Avatar of APS NZ

ASKER

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.

John