Google Sheets – Calculate Time Difference Within One Cell

google sheets

enter image description here

I'm trying to calculate the time difference and get the result 04:00. This obviously doesn't work because MINUS expects 2 arguments and instead gets a range.

Generally, is there a way to output a range into a function kind of like the ES6 spread syntax in Javascript?

Best Answer

You can use

=INDEX(SPLIT(F22, " - "),,2) - 
 INDEX(SPLIT(F22, " - "),,1)

enter image description here

This means we split the same cell twice.
Using INDEX we use the second column of the first split minus the first column of the second split.
(Of course you should format the result as duration.)

Related Topic