在A表中有一字段‘标记’记录时间,我想计算出今天和‘标记’所记录的时间的差怎么,怎么写代码?比如说今天是2003年5月2号,标记里记录的是2003年4月22号11点04分,我只需要差的天数请给的详细一点

解决方案 »

  1.   

    如果数据库是SQL Server有内置函数DateSpan,还是什么的,忘记了,你自己查查吧
      

  2.   

    Delphi里面也可以直接做减法。
      

  3.   

    i := ABS(ADOQuery1.FieldByName('标记').AsDate - Date);
    试试吧
      

  4.   

    SQL语句里面:
      select DateDiff(day,getdate(), Receivetime) as 相差天数 from 你的表;
    var
      i : integer;
    begin
    ...
      i := ABS(ADOQuery1.FieldByName('相差天数).AsInteger);
    ...
    end;
      

  5.   

    SQL语句里面:
      select DateDiff(day,getdate(), Receivetime) as 相差天数 from 你的表;
    var
      i : integer;
    begin
    ...
      i := ABS(ADOQuery1.FieldByName('相差天数).AsInteger);
    ...
    end;
      

  6.   

    Returns the number of days (including fractional days) between two specified TDateTime values.UnitDateUtilsCategorydate/time routinesfunction DaySpan(const ANow, AThen: TDateTime): Double;DescriptionCall DaySpan to obtain the difference, in days, between two TDateTime values. Unlike the DaysBetween function, which only counts whole days, DaySpan reports incomplete days as a fraction of an entire day.