Thanks Martina:
It seems that my mistake was assuming that a DATE variable sent as a parameter would remain a DATE variable when it is received. Apparantly, the drivers convert it to DATETIME format on the backend.
I'm not sure if this is a bug or feature.
FWIW.......
I got this problem because the sample code in the system I'm maintaining did something like
ldDate = DATE()
=SQLEXEC(lnHandle,"SELECT * from mytable WHERE;
DATE(AuditDate)= DATE('" + TRANSFORM(DTOS(ldDate),"@R 9999-99-99") +"')"
and I thought "It's
got to be easier to use a parameter."
>Hi Rich,
>
>Can be this
bug or this
bug.
>
>You try upgrade MySQL Server or try convert bind parameter to date:
>
>
>ldDate = DATE()
>=SQLEXEC(lnHandle,"SELECT * from mytable WHERE DATE(AuditDate) = CAST(?ldDate AS ADTE)")
>
>
>MartinaJ
>
>>In a MySQL table we have a DATETIME field AuditDate.
>>
>>I want to pull records from that table for a specific date
>>ldDate = DATE()
>>=SQLEXEC(lnHandle,"SELECT * from mytable WHERE DATE(AuditDate) = ?ldDate")
>>
>>Unfortunately, this pulls zero records. I know there are records for this date
>>ldDate = DATE()
>>=SQLEXEC(lnHandle,"SELECT AuditDate,DATE(AuditDate) ddd FROM myTable")
>>SELECT * FROM sqlresult WHERE TTOD(AuditDate) = ldDate ---> 171 records
>>SELECT * FROM sqlresult WHERE ddd = lddate ---> 171 records
>>
>>Can someone give me the proper syntax for getting a MySQL datetime field using a parameter.
>>
>>Muchly appreciated...............Rich