首先看你的数据库中年龄一项是什么标题,假设为AGE,则你可以建立一个BUTTON,书写程序: begin TABLE1.DisableControls; TABLE1.Filtered:=FALSE; TABLE1.Filter:='姓名='+''''+EDIT1.Text+''''; TABLE1.Filtered:=TRUE; TABLE1.EnableControls; end;procedure TForm3.SpeedButton2Click(Sender: TObject); begin TABLE1.DisableControls; TABLE1.Filtered:=FALSE; TABLE1.Filter:=''; TABLE1.Filtered:=TRUE; TABLE1.EnableControls; end;end. 当然,你先要对应好我程序里的TABLE和EDIT与你的编号相同。
select * from table where left(Ltrim(ym),4)+'.'+(case when len(Ltrim(ym))= 6 then '0'+right(Rtrim(ym,1)) else right(Rtrim(ym),2) end) between :s1 and :s2 看看这种思路行吗?
没看清楚题意,原来不考虑月份,那更简单些: select * from table where year(getdate())-cast(left(Ltrim(ym),4) as int) between :bage and :eage2
begin
TABLE1.DisableControls;
TABLE1.Filtered:=FALSE;
TABLE1.Filter:='姓名='+''''+EDIT1.Text+'''';
TABLE1.Filtered:=TRUE;
TABLE1.EnableControls;
end;procedure TForm3.SpeedButton2Click(Sender: TObject);
begin
TABLE1.DisableControls;
TABLE1.Filtered:=FALSE;
TABLE1.Filter:='';
TABLE1.Filtered:=TRUE;
TABLE1.EnableControls;
end;end.
当然,你先要对应好我程序里的TABLE和EDIT与你的编号相同。
where left(Ltrim(ym),4)+'.'+(case when len(Ltrim(ym))= 6 then '0'+right(Rtrim(ym,1)) else right(Rtrim(ym),2) end)
between
:s1 and :s2
看看这种思路行吗?
select * from table
where year(getdate())-cast(left(Ltrim(ym),4) as int)
between :bage and :eage2
[email protected]