'select * from table where time1>=:t1 and time1<=:t2' 在将参数f1,f2传给edit1.text 和edit2.text
'select * from table where time1>='+edit1.text+' and time1<='+edit1.text如果你用的是 Access的话要麻烦些,要分别比较年月日
如果用Query控件的话: var Btime,Etime:String; begin With query1 do begin Btime := edit1.Text; Etime := edit2.Text; if Active the Close; SQL.Clear; SQL.Add('select * from TableName where DateTime>= '''+Btime+''' and DateTime<='''+Etime+''''); Open;end;
这个问题要分几种情况 1)ADO +SQL SERVER数据库 日期一般用字符型 select*from TableName Where Date >='''+Edit1.text+''' AND Date<='''+Edit2.text+''' 2)QUERY+BDE with query1 do begin ..... 'select * from tableName where date between:t1 and :t2' ParamByName('t1').asstring:=edit1.text; ParamByName('t2').asstring:=edit2.text; end; 当然,你要保证Edit符合正确的日期格式;
完成同意 rmy(小任) ,方法有很多,最主要的是要保证人我的时间格式正确。
'select * from tableName where date between '+edit1.text+'and '+edit2.text'
在将参数f1,f2传给edit1.text 和edit2.text
Access的话要麻烦些,要分别比较年月日
var
Btime,Etime:String;
begin
With query1 do
begin
Btime := edit1.Text;
Etime := edit2.Text;
if Active the Close;
SQL.Clear;
SQL.Add('select * from TableName where DateTime>= '''+Btime+''' and DateTime<='''+Etime+'''');
Open;end;
1)ADO +SQL SERVER数据库 日期一般用字符型
select*from TableName Where Date >='''+Edit1.text+''' AND Date<='''+Edit2.text+'''
2)QUERY+BDE
with query1 do begin
.....
'select * from tableName where date between:t1 and :t2'
ParamByName('t1').asstring:=edit1.text;
ParamByName('t2').asstring:=edit2.text;
end;
当然,你要保证Edit符合正确的日期格式;