Launch code in new window » Download code as text file »
A co-worker of mine was getting this ColdFusion error message the other day and I was helping him debug the problem. Not knowing anything about his code, the problem was not obvious. I was looking for reference to undefined variables and other more obvious red flags. After dumping out a bunch of variable scopes it seems that all variables existed and had values or empty strings in them.
Since empty string is just a string value, I didn't give it much thought until I then went back to the line that was throwing the error. It was a DateDiff() method call. Then it was obvious. The problem was not that variables and values didn't exist, it was that a ColdFusion DATE/TIME object could not be created based on the variable value.
This is essentially what was causing the error:
Launch code in new window » Download code as text file »
This seems like a very cryptic error. Let's now compare it to one where a non-date object is passed to a function:
Launch code in new window » Download code as text file »
This, of course, throws an error because the value being passed into TestDateValue() is [""] which is NOT a date value. The error is very obvious and self-explanatory:
Launch code in new window » Download code as text file »
It would be nice if the DateDiff(), DateAdd(), and other such functions could throw similar errors. It makes me curious as to how those functions are working behind the scenes to validate variables.
Download Code Snippet ZIP File
Comments (1) | Post Comment | Ask Ben | Permalink | Other Searches | Print Page
Search Engine Optimization... Continued
SQL LIKE Clause Case Sensitive in ColdFusion MX Query-of-Query
Hi Ben,
I have same problem on my server now.
Here is my problem code. :)
<cfset startdate = CreateODBCDateTime(startdate)>
Have you found any solution?
Posted by O?uz Demirkap? on Feb 28, 2007 at 9:23 AM