<cfoutput> 
  <cfset mydate = 'June 01, 2008'> 
  <cfset JobStartDate=CreateODBCDateTime(mydate)> 
</cfoutput> 

Error: Date value passed to date function createDateTime is unspecified or invalid. Specify a valid date in createDateTime function.

Even isdate(mydate) // isdate('June 01, 2008') throws the exception. Even *DateDiff // DateDiff('m', 'June 01, 2008', 'October 14, 2010') also gives exception.

It works okay with other dates for example: 'August 01, 2008', 'May 14, 2012' etc

I am using ColdFusion 2021 Update 3. Any help would be highly appreciated?

Adding a few more details in response to the comments: Under JVM details Java Default Locale is en_US. Also by running GetLocale() gives me English (US). The issue does'nt reproduce on cftry or cffiddle. But it can be reproduced if you install Coldfusion via Commandbox and try running the code.

1

There are 1 answers

0
Marikkani Chelladurai On

Just do a lsParseDateTime to fix this. You are declaring that as a string so CF wont consider that as a date

<cfset JobStartDate = CreateODBCDateTime(lsParseDateTime(mydate, "en_US"))>