with query do
begin
close;
Sql.clear;
Sql.add('select * from table where date<=:date1 and date>=date2');
parameters[0]:=datetimetostr(datetime1.date);
parameters[1]:=datetimetostr(datetime2.date);
open;
end;
begin
close;
Sql.clear;
Sql.add('select * from table where date<=:date1 and date>=date2');
parameters[0]:=datetimetostr(datetime1.date);
parameters[1]:=datetimetostr(datetime2.date);
open;
end;
with query do
begin
close;
Sql.clear;
Sql.add('select * from table where date<=:date1 and date>=date2');
ParamByName('Date1').AsString :=FormatDateTime('yyyy-mm-dd',Datetime1.Date);
ParamByName('Date2').AsString :=FormatDateTime('yyyy-mm-dd',Datetime2.Date);
open;
end;
VarStr:String;
with query do
begin
VarStr:='select * from table where date<="'+DateTime1.Date+'"'+' and date>="'+DateTime1.Date+'"';
close;
Sql.clear;
Sql.add(VarStr);
open;
end;
SQL.Text:='select * from table where date<= '''+
FormatDateTime('yyyymmdd',Datetime1.Date)+''' and date>= '''+
FormatDateTime('yyyymmdd',DateTime2.Date)+'''';
open;
end;
02-1-1
02-1-15如果有这三条记录,
按照字符查找的话,
where date>='02-1-1' and date<='02-1-15' 应该是上面的三条全都满足。执行这条语句就显示
02-1-1
02-1-15
这两条记录。
02-1-3就没有显示了。
begin
close;
Sql.clear;
Sql.add('select * from table where date>=:begindate and date<=:enddate');
parameters[0]:=datetimetostr(datetime1.date);
parameters[1]:=datetimetostr(datetime2.date);
open;
end;