|
-
July 21st, 1999, 12:48 AM
#1
How to judge a time-typed field in SQL statement?
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?
-
July 21st, 1999, 01:54 AM
#2
Re: How to judge a time-typed field in SQL statement?
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 [email protected]
-
July 21st, 1999, 05:49 AM
#3
Re: How to judge a time-typed field in SQL statement?
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.
-
July 21st, 1999, 08:11 AM
#4
Re: How to judge a time-typed field in SQL statement?
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.
-
July 21st, 1999, 08:17 AM
#5
I know the reason & change it,but still wrong.
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
[email protected]
-
July 21st, 1999, 09:52 PM
#6
I have known the right answer
It should be "...dd>#1996/12/30#",
now I want to use SQLBindParameter,but how to send
this string to statement?
Best Regards
simon
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|