You can do this by making the Time_of_Start as well as the End time into an appropriate time type, and then using the DATEDIFF. The main thing to do is take into account the time that passes midnight.
Here's how you can accomplish this:
SELECT Test_ID, Start_Time, End_Time, RIGHT('0' + CAST(DATEDIFF(MINUTE, CAST(Start_Time AS TIME), DATEADD(DAY, CASE WHEN End_Time < Start_Time THEN 1 ELSE 0 END, CAST(End_Time AS TIME)) ) / 60 AS VARCHAR), 2) + ':' + RIGHT('0' + CAST(DATEDIFF(MINUTE, CAST(Start_Time AS TIME), DATEADD(DAY, CASE WHEN End_Time < Start_Time THEN 1 ELSE 0 END, CAST(End_Time AS TIME)) ) % 60 AS VARCHAR), 2) AS Elapsed_Time FROM Test;
This technique ensures that, If Start_Time is 23:45 and End_Time is 00.05 it gives you the correct time 00:20.
I typically recommend validating the results using the help of a calculation of time differences like a work time calculator, to double-check edges in the event of testing different start and ending time. This helps to avoid errors when calculations or sessions span over the night.
Regards,
Shozab