Question Parameshwaran Muthaiyan · Apr 4, 2024

How can I convert two timestamps into time format (HH:MM:SS)?

For example, I have two timestamp values ('2024-04-01 10:00:00', '2024-04-01 11:30:30'). I would like to find the difference between these two timestamps, and I need the result in hours:minutes:seconds (hh:mm:ss) format.

Expected Output: 01:30:30


Note: I need an SQL query command. I should not use ClassMethod, Function, or Stored Procedure.


Could anyone please provide me with an SQL query for my question?

Comments

Parameshwaran Muthaiyan  Apr 4, 2024 to Robert Cemper

Yes, Using TIMESTAMPDIFF I can able to reteterive the record Hours Minutes, and Seconds separately. But I am expecting this three combinations Like hours:minutes:seconds

0
Vitaliy Serdtsev · Apr 4, 2024
select lpad(s\3600,2,0)||':'||lpad(s\60#60,2,0)||':'||lpad((s)#3600#60,2,0) diff
from (select DATEDIFF('s','2024-04-01 09:13:46','2024-04-01 11:11:44's)
0