d1 := StrToDateTime('2002-2-10 12:12:30');
d2 := StrToDateTime('1980-3-19 23:55:00');
(d2 - d1) * 86400

解决方案 »

  1.   

    secondsbetween
    查查这个函数就可以了
      

  2.   

    用Delphi6的新函数,uses dateutils;
    function SecondsBetween(const ANow, AThen: TDateTime): Int64;
      

  3.   

    我用delphi5,delphi6的新涵数不能用!
    to: windindance(风舞轻扬) 
    你的86400从何而来???
    我算出来的数怎么还是和VC++的有区别!
      

  4.   

    edit1.text:=datetostr(datetimepicker2.date-datetimepicker1.date)
    对吗?结果不对呀
      

  5.   

    用VC得到的时间是1015907400秒, 我想用delphi也应是这个数
      

  6.   

    如果他们都是日期TDateTime的话,直接相减type TDateTime = type Double;Most VCL objects represent date and time values using the TDateTime type. The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is fraction of a 24 hour day that has elapsed. Following are some examples of TDateTime values and their corresponding dates and times:0 12/30/1899 12:00 am
    2.75 1/1/1900 6:00 pm
    -1.25 12/29/1899 6:00 am
    35065 1/1/1996 12:00 am
      

  7.   

    直接从Delphi6里面把这几个函数挖出来不就可以用了? 
     
      HoursPerDay   = 24;
      MinsPerDay    = HoursPerDay * 60;
      SecsPerDay    = MinsPerDay * 60;function SecondSpan(const ANow, AThen: TDateTime): Double;
    begin
      Result := SecsPerDay * SpanOfNowAndThen(ANow, AThen);
    end;function SecondsBetween(const ANow, AThen: TDateTime): Int64;
    begin
      Result := Trunc(SecondSpan(ANow, AThen));
    end;function SpanOfNowAndThen(const ANow, AThen: TDateTime): TDateTime;
    begin
      if ANow < AThen then
        Result := AThen - ANow
      else
        Result := ANow - AThen;
    end;
      

  8.   

    其实说白了也就是windindance(风舞轻扬) 的方法。
    你完全可以写成自己的函数。
      

  9.   

    谢谢!,
    我要长整型的. kevin_gao用你的算法算出来的数30066013688和1015907400差得很远.