I want to use Google Sheet as a time tracker. For example, in a cell, D3, I enter:
Gym 17:00-18:00I can extract the hours spent in Gym by:
=REGEXEXTRACT(D3,"Gym (\d{2}:\d{2}-\d{2}:\d{2})")Which returns:
17:00-18:00Now I want to subtract 18:00 from 17:00 and this is where I am stuck.If I use SPLIT function I get two outputs in two different cells which then I can subtract them from each other. However, I would like to perform the subtraction in the came cell I use REGEXEXTRACT. That is I am looking for some code to apply to REGEXEXTRACT to get the difference of the hours.
To subtract the hours properly I use:
=IF(C6-B6>0, HOUR(C6-B6)+MINUTE(C6-B6)/60, 24-(HOUR(B6-C6)+MINUTE(B6-C6)/60))C6 and B6 are the cells containing the output of SPLIT function.
Ideally I would like to combine REGEXEXTRACT with IF in the same cell so that that cell contains the amount of time spent in gym as specified in cell D3.