比如,在2009-1-1 18:00:00.000 加15分钟,返回2009-1-1 18:15:00.000,依此类推。

解决方案 »

  1.   

    tdatetime其实就是double,1表示1天,因此1分钟就是1/(24×60)
    加N分钟就把时间加上N/(24×60)
      

  2.   

    Delphi里有现成的函数可以实现日期加减,在DateUtils单元里的。 function IncYear(const AValue: TDateTime;const ANumberOfYears: Integer = 1): TDateTime;// function IncMonth is in SysUtilsfunction 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;
      

  3.   

    IncMinute( ) 就是分钟加减
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      ShowMessage(DateTimeToStr(IncMinute(now,15)));
    end;