我的代码如下,为什么我的查不到5月1的数据查不到.
sqltext:= 'select * from 200305.dbf where 日期>=:D1 and 日期<=:D2';
KQCXQuery.SQL.Add(sqltext);
KQCXQuery.ParamByName('D1').AsDateTime :=2003-05-01;
KQCXQuery.ParamByName('D2').AsDateTime :=2003-05-01;
sqltext:= 'select * from 200305.dbf where 日期>=:D1 and 日期<=:D2';
KQCXQuery.SQL.Add(sqltext);
KQCXQuery.ParamByName('D1').AsDateTime :=2003-05-01;
KQCXQuery.ParamByName('D2').AsDateTime :=2003-05-01;
KQCXQuery.SQL.Add(sqltext);
KQCXQuery.ParamByName('D1').AsDate :=StrToDate('2003-05-01');
KQCXQuery.ParamByName('D2').AsDate :=StrToDate('2003-05-01');
KQCXQuery.SQL.Add(sqltext);
KQCXQuery.ParamByName('D1').AsDate :=formatDate('yyyymmdd',StrToDate(2001-05-01));
KQCXQuery.ParamByName('D2').AsDate :=formatDate('yyyymmdd',StrToDate(2001-05-31));
KQCXQuery.SQL.Add(sqltext);
KQCXQuery.ParamByName('D1').AsDatetime :=StrToDate('2003-05-01');
KQCXQuery.ParamByName('D2').AsDatetime :=StrToDate('2003-05-01');
KQCXQuery.ParamByName('D2').AsString := '2003-05-01';就可以了.不需要用DateTime类型那么麻烦.