RT!
我需要的是小时,比如2小时,而不是1900-01-01 02:00:00.000
thx

解决方案 »

  1.   

    强制转换成整数就行了。
    Query1.FieldByName('value').AsInteger;
      

  2.   

    楼上的不行吧,TdateTime类型的1代表一天。
    用decodeTime吧,
    var
      Hour, Min, Sec, MSec:Word;
    begin
      DecodeTime(query1.FieldByName('value').asDataTime,hour,min,sec,msec);
      //hour就是你要的值了
    end;
      

  3.   

    有算时间差的函数
    UnitDateUtilsCategorydatetime routinesDelphi syntax:function HoursBetween(const ANow, AThen: TDateTime): Int64;
      

  4.   

    SELECT DATEDIFF(day, pubdate, getdate()) AS no_of_days
    FROM titles
      

  5.   

    Hour:=FormatDatetime('hh',strtodatetime(Query1.FieldValues['时间字段']));
      

  6.   

    谢谢各位,我已经用SQL中的datediff函数解决。谢谢各位,分数评分一下吧