datetime如何只取后面的time?
例如 TRS_DD 为dateTime字段,如何只取time (00:00:00)?
谢谢

解决方案 »

  1.   

    users DateUtils
    取年:yearof()
    取月:monthof()
    取日:dayof()
    小时:hourof()例子:users DateUtils
    str:string;str:=inttostr(yearof(date))+inttostr(monthof(date))+inttostr(dayof(date))+inttostr(hourof(now))+inttostr(minuteof(now))+inttostr(secondof(now)
    返回str:20030623123854
      

  2.   

    那我就用说了,楼上的都 说了!!!TIMEOF()
      

  3.   

    TimeOf的返回值为1899-12-31 09:00:08而且delphi5是没有这个函数的。
    可以用以方法得到。
    function ClearDate(theTime: TDateTime): string;
    var
      nHour, nMinute, nSecond, nMSecond: WORD;
    begin
        DecodeTime(theTime, nHour, nMinute, nSecond, nMSecond);
        result := Format('%s:%s:%s:%s', [IntToStr(nHour), IntToStr(nMinute), IntToStr(nSecond), IntToStr(nMSecond)]);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Caption := ClearDate(Now());
    end;我完全测试过。
      

  4.   

    FORMATDATETIME('h:n:s',query1.fieldBYNAME('TRS_DD').ASDATETIME);
      

  5.   

    up,up,up  哎,为什么我总是来晚呢
      

  6.   

    FormatDateTime('HH:MM:DD',TDateTime)