QueryExecute adding single quotes to datetime variable

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?

Thanks.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon
mso http://www.mso.net - Lucee http://lucee.org - Member

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?

Thanks.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon
mso http://www.mso.net - Lucee http://lucee.org - Member


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAG1WijX%2BAcBb_W2myyrxLtVp17ftsG-XdgdwiFHGSmuyRpa52w%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAG1WijX%2BAcBb_W2myyrxLtVp17ftsG-XdgdwiFHGSmuyRpa52w%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

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:


Adam