可以用decodedate过程来。
参考如下程序
procedure TForm1.Button1Click(Sender: TObject);
var
  Present: TDateTime;
  Year, Month, Day, Hour, Min, Sec, MSec: Word;
 begin
  Present:= Now;
  DecodeDate(Present, Year, Month, Day);
  Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
    + IntToStr(Month) + ' of Year ' + IntToStr(Year);
  DecodeTime(Present, Hour, Min, Sec, MSec);
  Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
    + IntToStr(Hour);
end;
以上程序出自delphi帮助文件的example

解决方案 »

  1.   

    select 字段1,字段2 from yourtable where 字段2-字段1=6 
    呵呵,就这么简单
      

  2.   

    楼上的朋友,我不能通过循环过程序完成。我数据量很大,可能有几十万条,为了速度,还必需在sql语句中一次检索完成,不知道哪位大侠有办法。
      

  3.   

    已知有两个字段,字段1,字段2,均为日期型。
    用一行sql语句,字段的年份减去字段1的年份等6的数据全部检索出来。select 字段1 Field1,字段2 Field2
    from yourtable 
    where Year(Field2)-Year(Field1)=6
      

  4.   

    select 字段一,字段二 from table where “字段一” - “字段二”=6 
    就这样,日期相减返回年份的
      

  5.   

    select *
    from Table1
    where DateDiff("yyyy", 字段1, 字段2) = 6
      

  6.   

    Year函数Access数据库不知道提供否,你查查F1。
      

  7.   

    写错了应该是cast是转化类型的命令,查找帮助看看吧