I am getting the following error "Root Cause Messa...
# cfml-general
m
I am getting the following error "Root Cause Message: M is an invalid date or time string." However when I run the exact same script using same database on CF2018 its fine. But the client has CF9 and running this exact same script on there brings up that error. Desperate for some help.
t
sharing some code might give us a chance, but I expect it is something to do with the formatting of the returned date
m
Hi @thisOldDave This is where its tripping. There is a dateformat there <cfqueryparam cfsqltype="CF_SQL_DATE" value="#dateformat(data_nascita,'dd/mm/yyyy')#">,
a
Why are you even calling
dateformat
there? The param expects a date, not a string.
But the error is suggesting that
data_nascita
contains - literally -
M
urgh... no... cos the
dateFormat
call would error before going to the DB. OK so that's weird.
Is it a JDBC error or a CF runtime error? Throwing us a bit more of a bone by sharing more of the error might help.
m
"Error","jrpp-3","05/10/22","112354","COMUNIVERSO","Root Cause Message: M is an invalid date or time string." Thats all I have from the logs chaps
"Warning","jrpp-3","05/10/22","112354",,"Thread: jrpp-3, processing template: C:\Inetpub\wwwroot\comuniverso\gest\import_sindaci_file.cfm, completed in 91 seconds, exceeding the 30 second warning limit"
just found this in the server log
I have set request timeout to 600 just in case so not sure why the server log is showing a warning
a
OK I checked
m is an invalid date or time string.
comes back from dateFormat if the first argument is
"m"
. So... err... the error is right. Don't do that.
your problem is to find out why
data_nascita
contains
"m"
. Nothing to do with the line of code you cited.
m
not with you??
a
which part?
m
ah ok yes so there is an invalid date in that field that is being read in from the csv
1
a
yup. You should be validating that data before you get anywhere need a DB query using it.
m
anything i can do to trap it ? so if invalid date just use current date?
a
depends on your business rules. I can't speak to those.
I'd be inclined to just throw an exception saying "fix yer frickin data and try again" (or some variant on that)
😂 2
m
if a date of birth is not provided then its a null .
a
but do that as part of validating the csv data, not as part of using the csv data
m
Ok got you cheers Adam 🙂
👍 1
a
And is null acceptable? If so you'll wanna monkey around with some conditional logic on that param as to whether to set the null attribute
👍 1