为了计算安全运行天数,要求在两edit中输入两个时间,然后求出此时间段内的天数,请问用什么函数实现?最好给出代码。谢了

解决方案 »

  1.   

    换用datetimepicker1和datetimepicker2,直接两个date相差可得天数.
      

  2.   

    用DaysBetween(const ANow, AThen: TDateTime): Integer;
    别忘了 uses DateUtils
      

  3.   

    只知道Sql里面有好的计算方法
    上面说的也不错了,直接用datetimepicker又省力,呵呵
      

  4.   

    STRTODATETIME(EDIT1.TEXT)-STRTODATETIME(EDIT2.TEXT)
      

  5.   

    var
      Date1,Date2 :TDateTime;
    如果只有日期可一用上面的方法Date1-Date2可以得到天数
    如果有时间就不行啦
    var 
      year1,month1,day1,year2,month2,day2:Word
    begin
    decodeDate(Date1,year1,month1,day1);
    decodeDate(Date2,year2,month2,day2);
    if (year1=year2) and (month1=month2) then
      result:=day2-day1;
    else
      if.......等
    end;
      

  6.   

    uses DateUtils

    DaysBetween(const ANow, AThen: TDateTime): Integer;