Tiago, you need a function that transforms the string in seconds,
kind of:
function GetSeconds(ATimeString: string): Integer;
var
Hour, Min, Sec, MSec: Word;
begin
DecodeTime(StrToTime(ATimeString), Hour, Min, Sec, MSec);
Result := Hour * 3600 + Min * 60 + Sec;
end;
This way you can add the seconds contained in the various strings.
Then you can turn the number of seconds into string again.
function SecondToTime(const Seconds: Cardinal): Double;
var
ms, ss, mm, hh, dd: Cardinal;
begin
dd := Seconds div SecPerDay;
hh := (Seconds mod SecPerDay) div SecPerHour;
mm := ((Seconds mod SecPerDay) mod SecPerHour) div SecPerMinute;
ss := ((Seconds mod SecPerDay) mod SecPerHour) mod SecPerMinute;
ms := 0;
Result := dd + EncodeTime(hh, mm, ss, ms);
end;
If you are using Oracle you can add up using the same database functions.
SUM STRING AS DATE - Oracle
http://www.delphitricks.com/source-code/strings/format_seconds_as_hhmmss.html
https://stackoverflow.com/questions/23420818/convert-hhmmss-to-seconds-or-minutes-with-delphi
Which database?
– Genos
You should not use Ttime, but Ttimespan. Ttime refers to a specific time of the day. Ttimespan applies to a duration.
– LS_ᴅᴇᴠ