select 姓名 from 表1 where Date()-生日>18 or (Date()-生日>18 and Date()-生日<25)
select * from Table where datepart(YYYY,getdate())-datepart(YYYY,生日)>=18 --18岁及以上
试试下面 with ADOQuery1 do begin close; connection:= adoconnection1; sql.clear; sql.add('select * from table where DATEDIFF(year, birthday, getdate())>18'); Open; end;
where datepart(YYYY,getdate())-datepart(YYYY,生日)>=18 --18岁及以上
with ADOQuery1 do
begin
close;
connection:= adoconnection1;
sql.clear;
sql.add('select * from table where DATEDIFF(year, birthday, getdate())>18');
Open;
end;