unit dttest;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls ;
type
TForm1 =
class(TForm)
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
DateTimePicker3: TDateTimePicker;
DateTimePicker4: TDateTimePicker;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
tg,std,min,sek,msek:word;
dtvon, dtbis, dtdiff: Tdatetime;
//DateTime von, DateTime bis, DateTime Differenz
s:
string;
begin
dtvon:=datetimepicker1.date+datetimepicker2.time;
dtbis:=datetimepicker3.date+datetimepicker4.time;
dtdiff:= dtbis - dtvon;
tg:=trunc(dtdiff);
//Tage berechnen
decodetime(dtdiff,std,min,sek,msek);
//Stunden, Minuten, Sekunden berechnen
// Ausgabe der Werte
str(tg,s);
label11.Caption:=s;
str(std,s);
label12.Caption:=s;
str(min,s);
label13.Caption:=s;
str(sek,s);
label14.Caption:=s;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// gleiche Startwerte setzen
datetimepicker1.date:=date;
datetimepicker2.time:=time;
datetimepicker3.date:=datetimepicker1.date;
datetimepicker4.time:=datetimepicker2.time;
// Ausgabewerte 0
label11.Caption:='
0';
label12.Caption:='
0';
label13.Caption:='
0';
label14.Caption:='
0';
end;
end.