tracker issue : CF-4204276

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

ParseDateTime() conversion issue

| View in Tracker

Status/Resolution/Reason: To Test//HaveNewInfo

Reporter/Name(from Bugbase): Jeff H. / ()

Created: 04/30/2019

Components: Language, Member Functions

Versions: 2018

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: 2018.0.03.314033 /

Priority/Frequency: Critical / Most users will encounter

Locale/System: English / Win 2012 Server x64

Vote Count: 1

Problem Description:

Date/Time values from a database query, when run through ParseDateTime() are not converted to valid datetime objects. Instead, they retain their original string value, causing all sorts of issues with trying to put those values back into a database.

Steps to Reproduce:

<cfquery name="getdate" datasource="dsn">
  SELECT getdate() AS datetime

  ts = getdate.datetime;
	ts: #ts#<br />
	ts: #ParseDateTime(ts)#<br />
	ts: #ParseDateTime(ToString(ts))#

Actual Result:

ts: 2019-04-29 20:00:20.503
ts: 2019-04-29 20:00:20.503
ts: {ts '2019-04-29 20:00:20'}

Expected Result:

ts: 2019-04-29 20:00:20.503
ts: {ts '2019-04-29 20:00:20'}
ts: {ts '2019-04-29 20:00:20'}

Any Workarounds:

After calling ParseDateTime(), check to see if the value matches what was sent in to ParseDateTime(). If they're the same, Call ParseDateTime() again, but this time wrap the argument value with ToString().