DateUtils.IncYear();
DateUtils.IncMonth();
DateUtils.IncWeek();
DateUtils.IncDay();
DateUtils.IncHour();
DateUtils.IncMinute();
DateUtils.IncSecond();
DateUtils.IncMilliSecond();


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
var
  t1,t2: TDateTime;
  i: Int64;
  d: Double;
begin
  t1 := StrToDateTime('2011-1-1 1:1:1');

  t2 := IncYear(t1);
  ShowMessage(DateTimeToStr(t2)); //2012-1-1 1:01:01

  t2 := IncYear(t1, 3);
  ShowMessage(DateTimeToStr(t2)); //2014-1-1 1:01:01

  t2 := IncMonth(t1);
  ShowMessage(DateTimeToStr(t2)); //2011-2-1 1:01:01

  t2 := IncWeek(t1);
  ShowMessage(DateTimeToStr(t2)); //2011-1-8 1:01:01

  t2 := IncDay(t1);
  ShowMessage(DateTimeToStr(t2)); //2011-1-2 1:01:01

  t2 := IncHour(t1);
  ShowMessage(DateTimeToStr(t2)); //2011-1-1 2:01:01

  t2 := IncMinute(t1);
  ShowMessage(DateTimeToStr(t2)); //2011-1-1 1:02:01

  t2 := IncSecond(t1);
  ShowMessage(DateTimeToStr(t2)); //2011-1-1 1:01:02

  t2 := IncMilliSecond(t1);
  ShowMessage(FormatDateTime('yyyy-m-d h:n:s:zzz', t2)); //2011-1-1 1:01:01:001
end;

end.


DateUtils-Function
posted on 2009-05-20 16:48  万一  阅读(13384)  评论(0编辑  收藏  举报