用formatdatetime函数,再用trunc函数!

解决方案 »

  1.   

    t1 := StrToDateTime('2002-01-01 01:01:00');
    t2 := StrToDateTime('2002-01-01 01:00:00');
    n:= (t2-t1) * 86400;
      

  2.   

    Button1.Caption := TimeToStr(StrToDateTime('2002-01-01  01:01:00')-StrToDateTime('2002-01-01  01:00:00'));
      

  3.   

    procedure TForm_Main.Button19Click(Sender: TObject);
    var Hour, Min, Sec, MSec: Word;
    begin
      DecodeTime(StrToDateTime('2002-01-01  01:01:00')-StrToDateTime('2002-01-01  01:00:00'), Hour, Min, Sec, MSec);
      ShowMessage(IntToStr(Hour) + '小时' + IntToStr(Min) + '分' + IntToStr(Sec) + '秒');
    end;
      

  4.   

    Min就是你需要的分,Sec就是你需要的秒,
      

  5.   

    谢谢 quark(夸克) 我实一下,OK,马上给分:)
      

  6.   

    Returns the second of the minute represented by a TDateTime value.UnitDateUtilsCategorydate/time routinesfunction SecondOf(const AValue: TDateTime): Word;DescriptionCall SecondOf to obtain the second of the minute represented by a specified TDateTime value. SecondOf returns a value between 0 and 59.Note: SecondOf returns the same value as the SecondOfTheMinute function.
      

  7.   

    日期时间实际就是float 型,所以只需相减后再用 decodetime 函数就可以分解出来了
      

  8.   

    老大,帮帮我,我都挑了N时间了,头都大了~
    给我答案OK?
      

  9.   

    这里有你想要的答案。
    http://www.csdn.net/expert/topic/561/561911.xml?temp=6.171817E-02
      

  10.   

    我用DecodeTime(StrToDateTime('2002-01-01 01:01:00')-StrToDateTime('2002-01-01 01:00:00'), Hour, Min, Sec, MSec); 
    OK
    但隔天呢?
      

  11.   

    var
      tempsec, sec, min, hour: integer;
    begin
      tempsec:=round(24*60*60*(strtodatetime('2002-01-02 01:01:50')-strtodatetime('2002-01-01 01:02:00')));
      sec:=tempsec mod 60;
      min:=((tempsec-sec) div 60) mod 60;
      hour:=(tempsec-sec-min*60) div 3600;
      showmessage(inttostr(hour)+'  '+
                  inttostr(min)+'  '+
                  inttostr(sec));
    end;
      

  12.   

    两个日期相减后,实际的值是一个double,整数部分是天,小数部分是毫秒
    自己换算
      

  13.   

    procedure TForm_Main.Button19Click(Sender: TObject); 
    var Year, Month, Day, Hour, Min, Sec, MSec: Word; 
    begin 
      DecodeDate(StrToDateTime('2002-01-01 01:01:00')-StrToDateTime('2002-01-01 01:00:00'), Year, Month, Day, ); 
      DecodeTime(StrToDateTime('2002-01-01 01:01:00')-StrToDateTime('2002-01-01 01:00:00'), Hour, Min, Sec, MSec); 
    end; 
    Year就是你需要的年, Month就是你需要的月, Day就是你需要的日, Hour就是你需要的时, Min就是你需要的分, Sec就是你需要的秒,