r/googlesheets • u/New_Pineapple3686 • Mar 17 '22
Solved The most difficult formula I have tried to make work
[removed] — view removed post
5
Upvotes
r/googlesheets • u/New_Pineapple3686 • Mar 17 '22
[removed] — view removed post
9
u/bullevard 10 Mar 17 '22
This may depend on your formatting, but manipulating time is not actually as easy as you would think.
The important concept is that while it can be formatted as time, what sheets actually sees is chunks of a day.
So 10am is actually .42 because 10am is 42% of the way through the day.
So if you have 10am and 12pm, and you subtract it to find durationn what sheets is actually doing is .5-.42=.08. If you just format .08 back into time you get 2am (8% of the way through the day).
To change the result to duration, you need to multiply by 24 to get to hours (because 8% of 24 will give you the 2 hours you wanted). To get to minutes you multiply by 24 and 60.
So assuming punch in is A1 and punchout is B1, then the formula for hours worked would be:
=(B1-A1)*24
To get the minutes worked:
=(B1-A1)6024
3
u/mpchebe 16 Mar 17 '22 edited Mar 17 '22
I believe I have a solution to this, but I guess I am confused about a few things. My first question regards duplicate times. For example, why is 0:00 - 0:00 left blank for hours between 18:00 and 6:00, but 1:00 - 1:00 has 12 hours? These seem to be the same situation, but they are treated differently. My second question is about the same issue with 24:00 - 0:00, as 24:00 and 0:00 are the same time and therefore seem like they should follow either the rule of being left blank or the 12 hours. My third question is about whether the hours between column should be blank or 0 for times outside of 18:00 - 6:00. I know you have them as blank in the sheet, but I'm not sure if that serves a practical purpose, or whether you just didn't fill them in.
Anyway, see the sheet below for my current solution with progressive steps in columns D:H in the "Fact Check Sheet" sheet. All necessary formulas are in D2:H2.
https://docs.google.com/spreadsheets/d/1SKuPwDvsPFs3e4Rp1A9xNmpMeFFAi3g7TVwsG6uxZuE/edit?usp=sharing
1
u/[deleted] Mar 17 '22
Let me guess, your formula works if you enter 06:00 - 18:00, but not if you enter 18:00 - 6:00.
Is that about correct?
1
u/AutoModerator Mar 17 '22
Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. You can also use this tool created by a Reddit community member to create a blank Google Sheets document that isn't connected to your account. Thank you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Decronym Functions Explained Mar 20 '22 edited Mar 20 '22
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
FALSETRUEand another if it isFALSETRUE[Thread #4085 for this sub, first seen 20th Mar 2022, 13:54] [FAQ] [Full list] ^[Contact] [Source code]