The formula failing is the following:
=IF(TIMEVALUE(C2 & ":00") > TIMEVALUE(B2 & ":00"); 0; C2-B2)
I previously tried
=IF(C2 > B2; 0; C2-B2)
but this also gives me "Error 502".
The cells it is referring to contains data in the format "12:30" (I formatted the columns with format "HH:MM").
I just want to calculate how much time lies between two times, respecting the special case where endtime < starttime.