I would install TurboPower Orpheus. Include the OvcDate unit in your uses statement. This example was produced with Berlin 10.1 Architect and is reasonably downward compatible. There are many versions of Orpheus.
procedure TForm2.SpeedButton1Click(Sender: TObject);
var
date1 : TDateTime;
date2 : TDateTime;
rdt1 : TStDateTimeRec;
rdt2 : TStDateTimeRec;
days : Integer;
seconds : Integer;
hrs : Integer;
min : Integer;
sec : Integer;
begin
date1 := StrToDateTime('01/05/2015 13:00');
date2 := StrToDateTime('02/05/2015 10:00');
rdt1.D := DateTimeToStDate(date1);
rdt2.D := DateTimeToStDate(date2);
rdt1.T := DateTimeToStTime(date1);
rdt2.T := DateTimeToStTime(date2);
DateTimeDiff(rdt1, rdt2, days, seconds);
hrs := seconds div SecondsInHour;
min := ((seconds - (hrs * SecondsInHour)) div SecondsInMinute);
sec := (seconds - (hrs * SecondsInHour) + (min * SecondsInMinute));
sec := sec;
// days = 30
// seconds = 75600
// hrs = 21
// min = 0
// sec = 0
end;
The above example establishes proof of concept and shows how the calculation works. Your input was 1.5.2015 and 2.5.2015 for the respective dates and that is what I used.
I would set up the appropriate calculation fields and place this formula in the OnCalc event. Be sure to establish a mechanism to set the start and stop datetime fields. Let the DBMS do the rest. I just happen to be one of the Most Popular Delphi Authors. http://cc.embarcadero.com/PopularAuthors.aspx