有没有函数可以用

解决方案 »

  1.   

    var
      time1,time2,time3:TDatetime;
      h,m,s:integer;
    begin
      time3:=time1-time2;
      decodetime(time3,h,m,s);
      result:=h*3600+m*60+s;
    end;
      

  2.   

    渔在帮助中查 IncHour看seealso
      

  3.   

    刚才是减
    现在 加
    decodedate(date,year,month,day); 
    date:=encodedate(year+5, month, day); 
      

  4.   

    Step.1 TDateTime -> 整数
    Step.2 整数 加、减、乘、除
    Step.3 整数 -> TDateTime//主要是看你要用什么为单位
    //参考如下函数
    DecodeTime();
    DecodeDate();
    EncodeTime();
    EncodeDate();
      

  5.   

    TDateTime=Double
    当然可以加、减、乘、除
    可是你想得到什么呢?
    日期乘日期是什么?
    这些诶函数可能会有用:
    function YearsBetween(const ANow, AThen: TDateTime): Integer;
    function MonthsBetween(const ANow, AThen: TDateTime): Integer;
    function WeeksBetween(const ANow, AThen: TDateTime): Integer;
    function DaysBetween(const ANow, AThen: TDateTime): Integer;
    function HoursBetween(const ANow, AThen: TDateTime): Int64;
    function MinutesBetween(const ANow, AThen: TDateTime): Int64;
    function SecondsBetween(const ANow, AThen: TDateTime): Int64;
    function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;{ Increment/decrement datetime fields }function IncYear(const AValue: TDateTime;
      const ANumberOfYears: Integer = 1): TDateTime;
    // function IncMonth is in SysUtils
    function IncWeek(const AValue: TDateTime;
      const ANumberOfWeeks: Integer = 1): TDateTime;
    function IncDay(const AValue: TDateTime;
      const ANumberOfDays: Integer = 1): TDateTime;
    function IncHour(const AValue: TDateTime;
      const ANumberOfHours: Int64 = 1): TDateTime;
    function IncMinute(const AValue: TDateTime;
      const ANumberOfMinutes: Int64 = 1): TDateTime;
    function IncSecond(const AValue: TDateTime;
      const ANumberOfSeconds: Int64 = 1): TDateTime;
    function IncMilliSecond(const AValue: TDateTime;
      const ANumberOfMilliSeconds: Int64 = 1): TDateTime;
      

  6.   

    如果你用Delphi做,那很费劲,Oracle里有个Interval函数可以做这个,但值能做100年那的加减操作。如果你是Delphi6,那请参考DateUtils单元文件,有不少现成的函数呢:
    function IncYear(const AValue: TDateTime;
      const ANumberOfYears: Integer = 1): TDateTime;
    // function IncMonth is in SysUtils
    function IncWeek(const AValue: TDateTime;
      const ANumberOfWeeks: Integer = 1): TDateTime;
    function IncDay(const AValue: TDateTime;
      const ANumberOfDays: Integer = 1): TDateTime;
    function IncHour(const AValue: TDateTime;
      const ANumberOfHours: Int64 = 1): TDateTime;
    function IncMinute(const AValue: TDateTime;
      const ANumberOfMinutes: Int64 = 1): TDateTime;
    function IncSecond(const AValue: TDateTime;
      const ANumberOfSeconds: Int64 = 1): TDateTime;
    function IncMilliSecond(const AValue: TDateTime;
      const ANumberOfMilliSeconds: Int64 = 1): TDateTime;
    ================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]