Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

How to use Google Sheet as a time tracker

$
0
0

I want to use Google Sheet as a time tracker. For example, in a cell, D3, I enter:

Gym 17:00-18:00

I can extract the hours spent in Gym by:

=REGEXEXTRACT(D3,"Gym (\d{2}:\d{2}-\d{2}:\d{2})")

Which returns:

17:00-18:00

Now 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.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>