How to get diff between start time and end time lazarus / 31-LCL ---------------------------------------------------------------------- greertr · 2016-11-27 20:22 This code is messy b/c I amd doing a lot of experimenting...but here is the procedure I'm trying to make work... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm2.ToggleBox1Change(Sender: TObject); var  HH,MM,SS,MS: Word;  Now: TDateTime;  When: TDateTime;  SystemTime: TSystemTime;  ST: TSystemTime;  strNow: string;  TS : TTimeStamp;  //cnt: integer;  dtStart, dtEnd: TDateTime;{sysutils  ...  The Date, Time and Now functions return the current date,time or combined date/time as a TDateTime value.}  begin  //initialize  //strNow := (DateTimeToStr(SystemTimeToDateTime(ST)));  //stringgrid2.Cells[4,1] := strNow;  TS:=DateTimeToTimeStamp (Now);  if ToggleBox1.Checked then;    begin       ToggleBox1.Caption := 'End Flight';      uELED1.Active:=true;      Stringgrid2.Cells[0,1] := datetostr(datetimepicker1.date);      dtStart := Now;      stringgrid2.cells[4,1] := timetostr(Now);    end;   if not ToggleBox1.Checked then    begin      ToggleBox1.Caption := 'Start Flight';      uELED1.Active:=false;      dtEnd := Now;      //format to jst hh:min      //FormatDateTime('hh:nn', dtEnd-dtStart);      stringgrid2.cells[4,1] := FormatDateTime('hh:nn', dtEnd-dtStart);     end; end;   I;vew got it now to where I get something in the Duration field of my little stringgrid, but, it's just zeroes.  Anyone able to help me on this? thx in adv ---------------------------------------------------------------------- bytebites · 2016-11-27 21:17 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if ToggleBox1.Checked then;    begin see where is ; ---------------------------------------------------------------------- greertr · 2016-11-27 22:30 thx! that fixed it  Guess i had gotten cross-eyed here's the code that worked... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm2.ToggleBox1Change(Sender: TObject); var  dtStart, dtEnd: TDateTime;{sysutils  ...  The Date, Time and Now functions return the current date,time or combined date/time as a TDateTime value.}{ An example from Delphi,,,. Vard1, d2 : TDatetime;Begin  d1 := StrToTime('09:10');  d2 := StrToTime('18:05');  ShowMessage(TimeToStr(d1-d2));End;}  begin  if ToggleBox1.Checked then    begin      ToggleBox1.Caption := 'End Flight';      uELED1.Active:=true;      Stringgrid2.Cells[0,1] := datetostr(datetimepicker1.date);      //dtStart := Now;      stringgrid2.cells[3,1] := timetostr(Now);    end;   if not ToggleBox1.Checked then    begin          ToggleBox1.Caption := 'Start Flight';          uELED1.Active:=false;          //dtEnd := Now;        stringgrid2.cells[5,1] := timetostr(Now);          dtstart := StrToTime(stringgrid2.cells[3,1]);          dtend := StrToTime(stringgrid2.cells[5,1]);          stringgrid2.cells[6,1] := FormatDateTime('hh:nn', (dtEnd-dtStart));    end;end; Greer