Converting seconds to HH:MM:SS

I have the following query that returns a total seconds value (up to 86400 seconds (1 day))

I want to convert this to an HH:MM:SS value. Any help is appreciated.

(SELECT FIRST TSS.TotalDrivingTime FROM HLG01_TR_TachographShiftSummary TSS WHERE TSS.DriverID = TRD.DriverID AND (CONVERT(date, TSS.PeriodStart))= S.LoadDate)

see if this link helps

Welcome.

What is TotalDrivingTime's data type?

Please be aware that this is a SQL Server forum.

"SELECT FIRST" is not SQL Server syntax.

try to find a similar syntax for your database technology as @ScottPletcher pointed out this forum is for SQL Server

declare @seconds table(TotalDrivingTime  int)

insert into @seconds
select 86400 union
select 86399 union
select 6700

SELECT 
case TotalDrivingTime
  when 86400 then '24:00:00:000'
  else TRY_CONVERT(varchar, DATEADD(ms, TotalDrivingTime * 1000, 0), 114)
  end
  from @seconds

At least tell us which dbms you are using? Sybase is my best guess, but it's just an (educated) guess.

Apologies - I'm not overly familiar with different SQL types. I think I now have a working solution.
thanks for your help.