Topic: Calculate time betwen two "Date time Picker"

Hi MVD community,

i am working on a project to calculate the time betwen two time picker...if you could help me with a push...it will be much appreciated!

Re: Calculate time betwen two "Date time Picker"

Hello popcorninicusor

Hope this could be a clue for you

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
   dt: TDateTime;
begin
     dt := Form1.DateTimePicker2.DateTime - Form1.DateTimePicker1.DateTime;
     ShowMessage(IntToStr(Trunc(dt)+1) + ' days');    //  Si on veut aller par ex du lindi au lundi suivant inclis
end;

Abother method ::

procedure Form1_Button1_OnClick (Sender: string; Action: string);
var     YY,MM,DD,YY2,MM2,DD2: integer;

begin
    DecodeDate(Form1.DateTimePicker1.Date, YY, MM, DD);
    DecodeDate(Form1.DateTimePicker2.Date, YY2, MM2, DD2);

    Form1.Label1.Caption := IntToStr(DD2-DD);
end;

Another method

procedure Form1_DateTimePicker1_OnChange (Sender: string);
begin
  form1.edit1.value:= form1.datetimepicker2.DateTime - form1.datetimepicker1.DateTime +1;
end;

Regards

JB

Re: Calculate time betwen two "Date time Picker"

Dear Jean,

thank you very much i realy apreceiated.,

but it is possibe to store it in to the database?(to see te calculate time)

Re: Calculate time betwen two "Date time Picker"

popcornelnicusor wrote:

Dear Jean,

thank you very much i realy apreceiated.,

but it is possibe to store it in to the database?(to see te calculate time)

Usually no need to store data in to the database, if you can calculate this data.

Dmitry.

Re: Calculate time betwen two "Date time Picker"

Dear gentelmans,

thank you for clarifying this topic for me.