例如rq是个日期型字段
我用
select name,sex,age from person where rq>=2002-12-16 and rq<=2002-12-18 and age>20报参数不足,期待是3; 我用select name,sex,age from person where rq>='2002-12-16' and rq<='2002-12-18' and age>20报类型错误; 我用select name,sex,age from person where rq>=to_date("2002-12-16","yyyy-MM-dd") and rq<=to_date("2002-12-18","yyyy-MM-dd") and age>20报函数未定义。 到底怎么用SQL语句比较日期型字段?谢谢
我用
select name,sex,age from person where rq>=2002-12-16 and rq<=2002-12-18 and age>20报参数不足,期待是3; 我用select name,sex,age from person where rq>='2002-12-16' and rq<='2002-12-18' and age>20报类型错误; 我用select name,sex,age from person where rq>=to_date("2002-12-16","yyyy-MM-dd") and rq<=to_date("2002-12-18","yyyy-MM-dd") and age>20报函数未定义。 到底怎么用SQL语句比较日期型字段?谢谢
害的我几天都没有搞定日期的查询!!!!!感觉自己笨,同时又感觉错误提示太差了,什么not match
而不是提示 should mm/dd/yyyy
靠 不知道Delphi开发者干嘛的
clientdataset1.commandtext:='select name,sex,age from person where rq>=:d1 and rq<=:d2 and age>20'
clientdataset1.params.parambyname('d1').asdate:=strtodate('2002-12-16');
clientdataset1.params.parambyname('d1').asdate:=strtodate('2002-12-18');
clientdataset1.open;
with adoquery1 do
beign
sql.clear;
sql.add ('select * from biao where rq like :p1');
parameters.fieldsbyname('p1').value :='2003-04-19'+'%';
active :=true;
open;
end;
var
Str,D:String;
begin...
//是Query则
Str:='select name,sex,age from person '
+'where rq>='''+formatDatetime('yyyy-mm-dd',D)+''''';
queryx.close;
queryx.sql.clear;
queryx.sql.add(Str);
queryx.open;
...
end;