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?
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())?