Calculate the difference between two datetime fields (yyyy-mm-dd hh:mm:ss) in time format (hh:mm:ss) in SQL server.
select start_datetime,
end_datetime,
right('0'+cast(datediff(second, end_datetime, start_datetime) / 3600 as varchar), 2)+':'+right('0'+cast((datediff(second, end_datetime, start_datetime) / 60) % 60 as varchar), 2)+':'+right('0'+cast(datediff(second, end_datetime, start_datetime) % 60 as varchar), 2) as duration_as_hhmmss
from table_name;