Here's the problem:
I'm letting a user search a database (MySQL) and one of the search fields is a date field. The user can then enter any date and I query the database to find any date that fits the query. I also have a field that specifies how precise the search should be. Here's the query:
Begin is the date column in the database:
<cfif IsDefined("form.match"
AND IsDefined("form.date_begin"
><cfif #Len(Trim(Form.match))# AND #Len(Trim(Form.date_begin))# >
AND Abs(DateDiff('d',Begin,#CreateODBCDate(Form.date_begin)#) )<= '#Form.match#'
</cfif></cfif>
This worked fine with mdb database but now I get an error:
ODBC Error Code = 42000 (Syntax error or access violation)
[TCX][MyODBC]You have an error in your SQL syntax near '('d',Begin,{d '2001-05-02'}) )<= '0' Order By ID DESC' at line 4
SQL = "Select * From E Where 1=1 AND Abs(DateDiff('d',Begin,{d '1900-05-02'}) )<= '0' Order By ID DESC"
Data Source = "SQL"
Thanks in advance
Alexander
I'm letting a user search a database (MySQL) and one of the search fields is a date field. The user can then enter any date and I query the database to find any date that fits the query. I also have a field that specifies how precise the search should be. Here's the query:
Begin is the date column in the database:
<cfif IsDefined("form.match"
AND Abs(DateDiff('d',Begin,#CreateODBCDate(Form.date_begin)#) )<= '#Form.match#'
</cfif></cfif>
This worked fine with mdb database but now I get an error:
ODBC Error Code = 42000 (Syntax error or access violation)
[TCX][MyODBC]You have an error in your SQL syntax near '('d',Begin,{d '2001-05-02'}) )<= '0' Order By ID DESC' at line 4
SQL = "Select * From E Where 1=1 AND Abs(DateDiff('d',Begin,{d '1900-05-02'}) )<= '0' Order By ID DESC"
Data Source = "SQL"
Thanks in advance
Alexander