the datelastmodified method

Discussion in 'Programming' started by Jamie18, Jun 25, 2007.

  1. #1
    hi, i'm trying to add something to my website that will search through a folder and delete any files more than 3 hours old whenever the page is loaded.
    i'm using the datediff method with parameters 'h', datelastmodified and now() but coldfusion is taking datelast modified to be June 7th, 2025 instead of june 25th, 2007.. so needless to say it isn't working in the desired way.

    this is my code

    <CFSET download_path = "#Application.File_Path#temp\">

    <cfdirectory action="list" name="filelist" directory="#download_path#">
    <cfoutput query="filelist">
    <!--- a few lines to show me what some values are --->
    datelastmodified #dateformat(datelastmodified,"mm/dd/yyyy")#
    datediff "#datediff("n", "#now()#", "#dateformat(datelastmodified,"mm/dd/yyyy")#")#"
    now #now()#

    <cfif datediff("h", datelastmodified, now()) gte 3>
    <cftry>
    <cffile action="delete" file="#download_path##Name#">
    <cfcatch type="any">
    </cfcatch>
    </cftry>
    </cfif>
    </cfoutput>

    anyone ever encountered this problem before? is there anyway i can force it to be recognized correctly?
     
    Jamie18, Jun 25, 2007 IP
  2. newbish

    newbish Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You may want to check and make sure there are no hot fixes that would correct this.
     
    newbish, Jun 26, 2007 IP
  3. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your debug code is very different than your CFIF code. So you may not be able to compare the results.

    
    datediff "#datediff("n", "#now()#", "#dateformat(datelastmodified,"mm/dd/yyyy")#")#"
    now #now()#
    
    <cfif datediff("h", datelastmodified, now()) gte 3>
    
    Code (markup):
    What do you get if you output the modified date (as is) and datediff("h", datelastmodified, now())?
     
    cfStarlight, Jun 26, 2007 IP