tracker issue : CF-4198662

select a category, or use search below
(searches all categories and all time range)
Title:

Date.diff method doesn't work correctly

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron ()

Created: 05/12/2017

Components: Language, Member Functions

Versions: 2016,11.0,13.0

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: ? /

Priority/Frequency: Normal / Some users will encounter

Locale/System: / Platforms All

Vote Count: 0

Repro:
https://trycf.com/gist/15aae49a3d46a75a716ca1b7ddeae69d/acf2016?theme=monokai
<cfscript>
d1 = now();
sleep(1000);
d2 = now();

writeOutput(dateDiff("s", d1, d2));
writeoutput("<br>");
writeOutput(d1.diff("s",  d2));

</cfscript>

Result:
1
-1

Looks to me like diff() is using the dates around the wrong way.

Nort really sure how this could have got through testing, TBH?

Attachments:

Comments:

I note the status of this was just changed to "as designed". I now await with eager anticipation the explanation of this "design".
Comment by Adam Cameron
741 | July 25, 2017 11:55:03 AM GMT
There is difference in dateDiff(datepart, date1, date2) and date1.diff(datepart, date2). dateDiff(datepart, date1, date2) ==> date2 - date1 date1.diff(datepart, date2) ===> date1 - date2 We are doing proper documentation for this difference and that will be available soon.
Comment by Ajay Rai
29797 | October 17, 2018 11:32:46 AM GMT
We have updated our doc --> [https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/DateDiff.html]
Comment by Dattanand M Bhat
29824 | October 23, 2018 07:12:42 AM GMT