使用EXTRACT函数。
//本年
with query1 do
begin
Close;
SQL.Clear;
SQL.Add(‘select * from tablename where EXTRACT(Year FROM datefield) =:a’);
parambyname('a').asinteger:=本年;
Open;
end;
//本月
with query1 do
begin
Close;
SQL.Clear;
SQL.Add(‘select * from tablename where EXTRACT(Year FROM datefield) =:a and EXTRACT(Month FROM datefield) =:b’);
parambyname('a').asinteger:=本年;
parambyname('b').asinteger:=本月;
Open;
end;
本日,不用了吧。