Hmm... thanks Brad and Mike for your quick replies. I have thought about
your answers deeply and decided they do make sense. :-)

I read the CF Docs too quickly and made the assumption (never good to
assume!) that the CF dateDiff() function works the same way as the SQL
dateDiff() function, which says: "When the user tells me where to look, I
only look at that value." So a specified "d" means disregard the hour and
minute values, and just return the difference in days.

Thanks again for your input!

On Mon, Apr 5, 2010 at 10:41 PM, Mike Chabot <[email protected]> wrote:

>
> If only two minutes separate timestamps, that is less than a day from
> my perspective, so the value should be 0. If 24 hours separate the two
> timestamps, that would be a one day difference.
>
> There are plenty of solutions to the problem. One is to remove the
> time element before doing the comparison. The best solution would
> depend on what you are trying to achieve, which I could only guess at.
>
> -Mike Chabot
>
> On Mon, Apr 5, 2010 at 10:05 PM, Qing Xia <[email protected]> wrote:
> >
> > 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:332617
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to