'How to show in full hours, the result like this. 8hrs./30minutes [duplicate]

I need to show the correct format and complete (8hrs/30mns)

SELECT TIMESTAMPDIFF(hour, MIN(Date1),MAX(Date1)) AS Daily Hours,
TIMESTAMPDIFF(minute, MIN(Date1),MAX(Date2)) AS Daily Minutes,
TIMESTAMPDIFF
('Daily Minutes' / 60,) AS full hours
FROM Attendance

see attached



Solution 1:[1]

SET @from_time = '2022-01-01 01:02:03';
SET @till_time = '2022-01-01 04:15:26';
SELECT @from_time time1,
       @till_time time2,
       TIMESTAMPDIFF(SECOND, @from_time, @till_time) diff_in_sec,
       SEC_TO_TIME(TIMESTAMPDIFF(SECOND, @from_time, @till_time)) diff_as_time,
       DATE_FORMAT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, @from_time, @till_time)), '%hhrs./%imns') diff_formatted;
time1 time2 diff_in_sec diff_as_time diff_formatted
2022-01-01 01:02:03 2022-01-01 04:15:26 11603 03:13:23 03hrs./13mns

db<>fiddle here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akina