Nope, it's working as designed. Here is an excerpt from the docs: "The DateDiff function determines the number of complete datepart units between the two dates; for example, if the datepart parameter is "m" and the dates differ by 55 days, the function returns 1."
So basically, using date diff is like using the floor operator, it is only counting the total number of COMPLETE days. Your example has a difference of only 2 minutes which is nowhere near a day. If you simply want to know if the files were created prior to midnight of the current day, then you should check for that specifically with something like so: <cfset variables.yesterday = "04-04-2010 11:59 PM"> <cfset variables.today = "04-05-2010 12:01 AM"> <cfoutput>#yesterday LT dateformat(today,"mm/dd/yyyy")#</cfoutput> ----- Original Message ----- From: "Qing Xia" <[email protected]> To: "cf-talk" <[email protected]> Sent: Monday, April 05, 2010 9:05 PM Subject: ColdFusion dateDiff() function? > > Okay, I am probably splitting hairs over here, but I ran into an icky > situation with the native ColdFusion function DateDiff() today and just > thought I'd check whether anyone else has experienced this before. > > Basically, I wrote a CF Scheduled Task that is supposed to go to a > directory > and delete all PDF files that are created before today. Simple enough, > right? It should be really, but the DateDiff() function is behaving > strangely. Try running the code below: > > <cfset variables.yesterday = "04-04-2010 11:59 PM"> > <cfset variables.today = "04-05-2010 12:01 AM"> > <cfoutput>today - yesterday = #dateDiff("d",yesterday,today)#</cfoutput> > > You see how it thinks the the date difference is ZERO??? Shouldn't it be > ONE???!!! There are ways to get around this (elegantly or otherwise)... > but > now I am just irked and curious. Is this expected behavior and I am just > not > understanding the function correctly or is this a bug that should get > fixed? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332615 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

