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?
Discussion (0)0
Comments
did you check TIMESTAMPDIFF ??
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
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)Thanks @Vitaliy Serdtsev
It's working as expected.