Click to See Complete Forum and Search --> : How to judge a time-typed field in SQL statement?


smn
July 21st, 1999, 12:48 AM
I want to use a SQL statement with condition to get records,
the condition is date>DEC. 30,1996. But the database returns
error, either I look on the "date" field as CHAR-typed or
VALUE-typed. In my program, this field named "date" is CTIME-
typed in CRECORDSET,while SQL_C_CHAR-typed in SQLALLOCHANDLE.
Whatever I type like these,they don't work:
sr=SQLExecDirect(stmt,
(SQLCHAR*)"select * from stock where date='19961230'"
,SQL_NTS);

sr=SQLExecDirect(stmt,
(SQLCHAR*)"select * from stock where date>19961230"
,SQL_NTS);
Can anybody help me,please?

Daniel Zilcsak
July 21st, 1999, 01:54 AM
I'm not sure of this but i also got an arror like that in mySQL. Try to rename that field from date to _Date or date1 or something like that. I did so and it worked. The mySQL missunderstood the date directive, and I gues yout sql does it too.
Hope this would help...


Regards,
Dani Zilcsak
mailto:daniel_zilcsak@hotmail.com

Bob Place
July 21st, 1999, 05:49 AM
Isn't date a key (or reserved) word in most DBs? I would change the name of the field to something else and try it then.

smn
July 21st, 1999, 08:11 AM
I change the field name "date" to others,like
dd,aa or else,but the "sr" still returns SQL_ERROR.
I really have no idea now.

Thank you all for your reply.

smn
July 21st, 1999, 08:17 AM
SQLDATE[]="19961230";
sr=SQLExecDirect(stmt,
(SQLCHAR*)"select * from stock where dd>d",
SQL_NTS);
I have sent a SQLDATE variable to statement,
unfortunately,wrong again.

simon
smn@21cn.com

smn
July 21st, 1999, 09:52 PM
It should be "...dd>#1996/12/30#",
now I want to use SQLBindParameter,but how to send
this string to statement?

Best Regards
simon
smn@21cn.com