Selected Answer
Here are the two fomulas you need.
[K25] =MIN(SUM(($D25-$C25),($F25-$E25),($H25-$G25),($J25-$I25)),0.5)
and
[L25] =MAX(SUM(($D25-$C25),($F25-$E25),($H25-$G25),($J25-$I25))-0.5,0)
K25 will show the sum of all the times worked to a maximum of 12 while L25 will show the whatever is in addition to 12 based on the same sum. In both formulas 0.5 represents half a day = 12 hours. Make sure that both cells have the custom NumberFormat hh:mm so that they can display times..
Your formula, mistaken though it appears in its use of the MEDIAN() function, seems to want to take account of worktime ending on the next day. This is something the above formulas don't do. In order to do that you would need to change the way you enter times in Sheet1. I urge you to read up on how Excel records and displays times and dates.
Start with reformatting Sheet1!A3 with the custom NumberFormat "d/m" (enter without quotation marks). Then, when you enter 2/4 in the cell Excel will record 2.4.2018, adding the current year automatically. If you need 2.4.2017 you must specify the year in your entry. Due to the format, either entry will display "2/4". In A4 enter =$A3+1 and copy down.
Next format Sheet1!B3 the the custom NumberFormat "ddd" (no quotation marks) and enter the formula =$A3. Now this cell will have the exact same date (2.4.2017) as its neighbour in column A but will display "Sun". Cope the formula down as required.
The formula [Template!A3] =Sheet1$A3 will now import a proper date. You will need to apply the same format as on Sheet1. Repeat with [Template!B3] =Sheet1$B3 and copy both cells down as required.
[Template!A24] =Sheet1$A3 is better than [Template!A24] =$A3 for purposes of maintenance. You want to know where the value comes from. However, the effect of the whole exercise is to know which date is referred to in the IN and OUT columns C:J, and that would give you the capability to modify calculations like ($D25-$C25) to give the correct result if C25 is on the next day.