Eric
With :
StartTime:= Now;
/// Some time goes by
EndTime := Now;
TimeDifference := EndTime - StartTime;
strTimeDifference := FormatDateTime('dd" days", hh" hours", nn" minutes", ss" seconds"', TimeDifference);
If I let the process run for 30 seconds I get : "30 days, 0 hours, 0 mins, 30 secs"
If I let the process run for 8 seconds I get : "30 days, 0 hours, 0 mins, 8 secs"
If I let the process run for 6 seconds I get : "30 days, 0 hours, 0 mins, 6 secs"
WP
StartTime is TDateTime
EndTime is TDateTime
By my understanding of the FPC command "SecondsBetween" was that it returned the number of whole seconds between between one date and the next and it expects two TDateTime vars, AThen and ANow (i.e, starttime and endtime) and it returns an Int64, i.e. the number of whole seconds, e.g. 8, or 60, or 50. So that's why I was trying to then convert those seconds to HH:MM:SS.
What I didn't realise until you explained it to me was that you could simply have 3 TDateTimes - StartTime, EndTime and then the difference between the two could also be measured as TDateTime and then formatted as ou demonstrated.
So this now works (thanks to both of you) and pasted for the benefit of others:
var
StartTime, EndTime, TimeDifference : TDateTime;
strTimeDifference : string;
begin
// Compute the end time and how long it took. Only for the GUI.
EndTime := Now;
lblEndTimeB.Caption := FormatDateTime('dd/mm/yy hh:mm:ss', EndTime);
TimeDifference := EndTime - StartTime;
strTimeDifference := FormatDateTime('h" hrs, "n" min, "s" sec"', TimeDifference);
lblTimeTakenB.Caption := strTimeDifference;end;