Количество дней между датами

Написать программу подсчитывающая количество дней между двумя датами.

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ComCtrls, Grids, Calendar;

type

TForm1 = class (TForm)

Button1: TButton;

DateTimePicker1: TDateTimePicker;

DateTimePicker2: TDateTimePicker;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

procedure Button1Click (Sender: TObject);

procedure DateTimePicker1Change (Sender: TObject);

procedure DateTimePicker2Change (Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

uses DateUtils;

{$R *.dfm}

procedure TForm1.Button1Click (Sender: TObject);

begin

Label1.Caption:=('количество дней = '+inttostr (Round (DateTimePicker2.Date-DateTimePicker1.Date)));

end;

procedure TForm1.DateTimePicker1Change (Sender: TObject);

begin

if DateTimePicker1.Date>DateTimePicker2.Date then

ShowMessage ('эта дата не должна превышать  ' +DateToStr (DateTimePicker2.Date));

end;

procedure TForm1.DateTimePicker2Change (Sender: TObject);

begin

if DateTimePicker2.Date<DateTimePicker1.Date then

ShowMessage ('эта дата не должна быть меньше  ' +DateToStr (DateTimePicker1.Date));

end;

end.

About admin

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Подтвердите, что Вы не бот — выберите самый большой кружок: