字段类型为datetime,
格式为11:02:03我想算出该时间的用秒计算的数值,
如果转化成string类型,
tottime:= strtofloat(copy(pdatetime,1,2))*3600+strtofloat(copy(pdatetime,4,2))*60+strtofloat(copy(pdatetime,7,2));使用上述语句,却报错,
我分析原因是如果格式为00:00:01的话,
取到的值就有问题,有没有ASP中的hour()类似的涵数?在线等待!

解决方案 »

  1.   

    Returns the second of the minute represented by a TDateTime value.UnitDateUtilsCategorydatetime routinesDelphi syntax:function SecondOf(const AValue: TDateTime): Word;C++ syntax:extern PACKAGE Word __fastcall SecondOf(const System::TDateTime AValue);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.
      

  2.   

    sorry,make a mistake;
    Returns the number of seconds between two specified TDateTime values.UnitDateUtilsCategorydatetime routinesDelphi syntax:function SecondsBetween(const ANow, AThen: TDateTime): Int64;C++ syntax:extern PACKAGE __int64 __fastcall SecondsBetween(const System::TDateTime ANow, const System::TDateTime AThen);DescriptionCall SecondsBetween to obtain the difference, in seconds, between two TDateTime values. SecondsBetween counts only entire seconds. Thus, SecondsBetween reports the difference between 9:00:00 AM and 9:00:00:999 AM as 0 because the difference is one millisecond short of an entire second.
      

  3.   

    uses dateutils;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      t:Tdatetime;
    begin
      t:=strtotime('11:01:01');
      showmessage(inttostr(secondsbetween(t,0)));
    end;
      

  4.   

    ShowMessage(FloatToStr(now()-StrToDateTime('2003-10-19 12:00:00 AM')));
      

  5.   

    原因可能是,字段类型为datetime,显示格式为11:02:03,但是存储的是一个数,应该先将其专存成字符,看看什么格式再处理。