tracker issue : CF-4202965

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

DateConvert Function seems corrupt.

| View in Tracker

Status/Resolution/Reason: To Track//PRNeedInfo

Reporter/Name(from Bugbase): Michael Grant / ()

Created: 06/21/2018

Components: Tags

Versions: 11.0

Failure Type: Data Corruption

Found In Build/Fixed In Build: 11,0,14,307976 /

Priority/Frequency: Normal / All users will encounter

Locale/System: English / Windows 10 64 bit

Vote Count: 1

Problem Description:
Using DateConvert() inside DateAdd() creates a corrupt date/time object.
Please refer to this conversation https://forums.adobe.com/message/10459206#10459206

Steps to Reproduce:
Please refer to this conversation https://forums.adobe.com/message/10459206#10459206

Actual Result:
Evaluating two time objects gives unexpected results. Time 2 evaluates as earlier than Time 1

Expected Result:
Time 1 is later than Time 2.

Any Workarounds:
Wrapped DateAdd() function in ParseDateTime() to get a proper date/time object.

Attachments:

Comments:

Correction: Under "actual result" it's actually Time 1 that evaluates as earlier than Time 2. In my test time1 was: {ts '2018-06-20 15:12:00'} and time2 was {ts '2018-06-20 09:00:00'} yet time1 evaluated as false when I did a GTE than time2. Sorry for the confusion.
Comment by Michael Grant
29121 | June 21, 2018 04:40:36 PM GMT
I can confirm this problem exists for CF 11,0,14,307976 JAVA 1.8.0_151
Vote by Eddie Lotter
29122 | June 21, 2018 04:41:20 PM GMT
@Michael We could see that you have used getDate() in the code, if you are setting anything specific to time zone or locale in this function please share with us, it would be helpful for us to repro. We tried the code below, we have used now() instead of getDate(). It worked as expected. <!--- Set date ---> <cfset thisDate = now()> <!--- Determine what flight they should see. ---> <!--- If it's after 9am and before 10pm ---> <cfif thisDate GTE CreateDateTime(DatePart("yyyy",thisDate),DatePart("m",thisDate),DatePart("d",thisDate),9, 0,0) AND thisDate LT CreateDateTime(DatePart("yyyy",thisDate),DatePart("m",thisDate),DatePart("d",thisDate),21 ,0,0)> <cfset d1 = "#DatePart('m',thisDate)#/#DatePart('d',thisDate)#/#DatePart('yyyy',thisDate)# 9:00:00"> <cfset d2 = "#DatePart('m',thisDate)#/#DatePart('d',thisDate)#/#DatePart('yyyy',thisDate)# 21:00:00"> <cfoutput>If it's after 9am and before 10pm</cfoutput> <!--- If it's after 10pm ---> <cfelseif thisDate GTE CreateDateTime(DatePart("yyyy",thisDate),DatePart("m",thisDate),DatePart("d",thisDate),21 ,0,0)> <cfset d1 = "#DatePart('m',thisDate)#/#DatePart('d',thisDate)#/#DatePart('yyyy',thisDate)# 21:00:00"> <cfset d2 = "#DatePart('m',thisDate)#/#DatePart('d',thisDate)#/#DatePart('yyyy',thisDate)# 9:00:00"> <cfset d2 = DateAdd("d",1,d2)> <cfoutput>If it's after 10pm</cfoutput> <!--- If it's before 9am ---> <cfelse> <cfset d1 = "#DatePart('m',thisDate)#/#DatePart('d',thisDate)#/#DatePart('yyyy',thisDate)# 21:00:00"> <cfset d1 = DateAdd("d",-1,d1)> <cfset d2 = "#DatePart('m',thisDate)#/#DatePart('d',thisDate)#/#DatePart('yyyy',thisDate)# 9:00:00"> <cfoutput>If it's before 9am</cfoutput> </cfif>  
Comment by Dattanand M Bhat
29251 | July 06, 2018 09:25:52 AM GMT
@Dattanand, you won't see the problem when setting "thisDate" to now(). As the OP points out, the issue surfaces when using the DateConvert() function inside of the DateAdd() function. Please see the referenced thread for reproducible examples.
Comment by Eddie Lotter
29447 | August 08, 2018 08:14:37 PM GMT