tracker issue : CF-4100088

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

[ANeff] Bug for: dateAdd() milliseconds does not work

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 12/15/2015

Components: Language

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 1

dateAdd() milliseconds does not work

Repro:

<cfscript>
  dateTime = createDateTime(2016,1,3,1,2,3);
  dateAdd("l", 456, dateTime);
  writeOutput(dateTimeFormat(dateTime, "yyyy-mm-dd HH:nn:ss.lll"));
  
  sdf = createObject("java", "java.text.SimpleDateFormat").init("yyyy-MM-dd HH:mm:ss.SSS");
  writeOutput('<br>' & sdf.format(dateTime));
</cfscript>

Actual result:
2016-01-03 01:02:03.000
2016-01-03 01:02:03.000

Expected result:
2016-01-03 01:02:03.456
2016-01-03 01:02:03.456

Verified in CF11 Update 7 (build 11,0,07,296330).

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4100088

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email:

Attachments:

Comments:

+1 .....................................
Vote by External U.
5097 | December 15, 2015 06:40:14 AM GMT
Aaron, I think the method is supposed to return an object with added time units, not modify the object passed as the argument. Can you pls try the following and share the result: _dt = createDateTime(2016,1,3,1,2,3); _dt_millis = dateAdd("l", 456, _dt); writeOutput(dateTimeFormat(_dt_millis, "yyyy-mm-dd HH:nn:ss.lll")); If you prefer calling a method on the object to do the same job, you can try using the java methods directly, something like: dateTime = createDateTime(2016,1,3,1,2,59); dateTime.setTime(dateTime.getTime() + 456);
Comment by Piyush K.
5094 | December 19, 2015 01:33:20 PM GMT
Hi Piyush, I'm sorry; you're right! I wasn't paying attention. This can be closed as NotABug :) Thanks!, -Aaron
Comment by External U.
5095 | December 19, 2015 05:46:01 PM GMT
And thanks, Piyush, for the example using Java methods directly.
Comment by External U.
5096 | December 19, 2015 05:49:30 PM GMT