I’ve got a weird issue with QueryExecute adding single quotes to a datetime
variable. I have the following:
queryExecute("
SELECT col1,
col2
FROM table
WHERE col_date > :varDate",
{varDate=arguments.aDate, cfsqltype=“cf_sql_datetime”}
);
This results in the varDate looking like this:
‘{ts ‘‘2015-02-13 10:10:33’’}’
when it should be:
{ts ‘2015-02-13 10:10:33’}
These extra single quotes cause the query to not return any results.
However if I change the queryExecute to simply use the date passed into the
function directly, which I obviously don’t want to do, it works fine.
Has anyone else experienced this or do I have something wrong in the above
way I have used queryExecute?
Try using cf_sql_date I don’t think date time is a valid option
ASent from my phone
On 8 Mar 2015 23:29, “Andrew Dixon” <@Andrew_Dixon> wrote:
Hi All,
I’ve got a weird issue with QueryExecute adding single quotes to a
datetime variable. I have the following:
queryExecute("
SELECT col1,
col2
FROM table
WHERE col_date > :varDate",
{varDate=arguments.aDate, cfsqltype=“cf_sql_datetime”}
);
This results in the varDate looking like this:
‘{ts ‘‘2015-02-13 10:10:33’’}’
when it should be:
{ts ‘2015-02-13 10:10:33’}
These extra single quotes cause the query to not return any results.
However if I change the queryExecute to simply use the date passed into the
function directly, which I obviously don’t want to do, it works fine.
Has anyone else experienced this or do I have something wrong in the above
way I have used queryExecute?
If it assumed it was a string then surely escaping the single quotes would
be correct?
The only time one needs to escape single quotes is when the string in
questions is hard-coded in the SQL statement. When it’s being passed as a
param, the reason for doing this escaping isn’t present, so it shouldn’t
need to be done.On Monday, 9 March 2015 10:23:18 UTC, Andrew Dixon wrote: