Google Sheets - If worked past midnight - if-statement

I am trying to return a value (Yes, or No) if the shift was worked through midnight on a time card.
=IF($P$10=MEDIAN(B3,C3,$P$10),"Yes","No")
This seemed the most promising of anything I was able to find or try, but I am having no luck what so ever.
Furthermore, I would like to add a column of Hours worked since midnight. I am also having no luck with that.
Is there any way I can achieve this in Sheets?
An example. If I got this column to say YES worked past 12AM then I would use that YES in an IF function to calculate how many hours since 12AM was the OUT time.
Another Example. If time in is 4PM and time out is 2AM then this column would say Yes 12AM is between those times
If time in was 7AM and time out was 3PM it would say No 12AM is not between those times.
Look at the TIME CARD sheet
MY FULLY EDITABLE SHEET
Formulas I have attempted
=MEDIAN("12:00:00 AM",TIMEVALUE(B4), TIMEVALUE(C4))="12:00:00 AM"
Have Also Used a Cell with 12 AM, and without the seconds.
=AND($P$10>B3,$P$10<C3)
=IF(MEDIAN($P$10,B3,C3)=$P$10, "Yes", "No")

use:
=ARRAYFORMULA(IF(C3:C9<B3:B9, TRUE))
or shorter:
=ARRAYFORMULA(C3:C9<B3:B9)

I've edited your formula on your worksheet with a bit of a workaround. If the day goes from PM to AM then it's true, else it's false.
=if(and(RIGHT(B3,2)="PM",RIGHT(C3,2)="AM"),"yes","no")
I hope this helps
CMike

I Have Solved This! The problem I had was no date data, therefor the times being compared were not accurate.
This little workaround did the trick.
=$P$10+($P$10<B3)=MEDIAN($P$10+($P$10<B3),B3,C3+(C3<B3))

Try my hour sheet in your Google Sheet:
https://docs.google.com/spreadsheets/d/1brscTwgrCSV4RiTkZurGrsyGRfbPV32BkiRzUTnMtE8/edit#gid=921019529
To check weather hours worked surpass the current date simply use:
=IF(F42<E42;"yes";"no")
=IF(endtime<starttime;midnight_has_passed;midnight_has_not_passed)

Related

Can you make a if statement with time and date as

Is it possible to make an If and AND statement that will show a specific day if the time and date follows?
Like for example 2/13/2021(3 am) up to 2/14/2021 (3:00 am) be counted as 2/13/2021?
And it will automatically the same thing will happened with 2/14/2021 3:01 am and so on?
I was think of using if and now() but I have no idea how to code it and if today ends will the dates that are currently in the cell changes too?
Thank you in advance
https://docs.google.com/spreadsheets/d/1R7dnbN7UAtZ-uC6Knwp6YKAqW-K3EW34jORBXbemg7Y/edit?usp=drivesdk
try:
=ARRAYFORMULA(TEXT(A1:A3-3/24, "dd/mm/yyyy"))

What is a working formula that can calculate to show if an appointment time has surpassed two hours by referencing the current time

I'm currently tying up a work project in Google Sheets, but I'm stuck on an addition that I would like to add. I had an idea to show whether an input appointment time had surpassed a 2 hour window while referencing the current time. I tried the code below but I keep getting N/A returns or #error. Any help would be appreciated.
"=IF(A2+TIME(2,0,0)<(TEXT(NOW()'HH:mm'), 'YES', 'NO')"
Basically if the input time in cell A2 plus two hours is less than the current time, it would state yes or no. I admit my knowledge although growing, is still a bit basic. Thanks for any advice or suggestions.
Try this:
=IF(A2+(2/24)<now(), "YES", "NO")

Google Sheets hours worked before and after specified time

I am trying to specify a time that starts a shift premium for a time card. I was so happy I finally figured out how to get it, but then I changed a time to a first shift time and thats when I lost all hope. I have spent hours messing with this and my current formula's looks like
x1.05
=IF(COUNT(A20:B20)=2,MOD($B$18-A20,1)*24,"")
x1.1
=IF(COUNT(A20:B20)=2,MOD(B20-$B$18,1)*24,"")
My end goal is to have it so first shift (7am - 3pm) fall under base pay, 2nd shift (4pm-12am) fall under x1.05 and anything past 12am falls under x1.1
Just getting this far has been a mind blower for me and any help would be greatly appreciated.
I have moved this to its own sheet to share with everyone. I am still playing with things myself and trying different things, but on the sheet I have included the variables along with the wording of the contract that effects the pay scale. NOTE the times I originally provided were just examples from the top of my head.
My Sheet
It doesn't look like your current sheet accounts for the multiple criteria you're wanting to evaluate. First shift (x1) begins at 7; second shift (x1.05) begins at 15:00, and third shift (x1.10) begins at 24:00.
I added each of those directly above the columns they affect and used this formula for the Base column:
=IF(COUNT($A20:$B20)=2,IF($A20<F$18,(MOD(MIN(F$18,$B20)-$A20,1))*24,0),"")
...this for the x1.05 column:
=IF(COUNT($A20:$B20)=2,IF($A20<G$18,(MOD(MIN(G$18,$B20)-$A20,1)*24)-E20,0),"")
...and this for the x1.10 column:
=IF(COUNT($A20:$B20)=2,(MOD(MIN(E$18+1,$B20)-$A20,1)*24)-SUM(E20:F20),"")
So far, it's working as expected. One thing I didn't add into it is to account for someone who starts their shift before 7 a.m. If you want this to be included in the x1.10 column, you could add a calculation for that to the formula there.
Here's what it looks like:
I'm working in Excel, but these formulas should all work in Google Sheets as well.

COUNTIF ? I need to count dates, but only once

I have a sheet that has become complex, it has a lot of filters and I need to populate a table with data. I am counting how many times a month we run a product. If we run it once a day, or more, I want to only count that as one.
Date Product Grizzly
1/1 2.5 open
1/1 1.5 closed
1/1 2.5 closed
1/1 2.5 open
Something a little more elaborate than this, but what I need is to count this as one day of 2.5 grizzly closed, instead of two.
Any help? I feel like there is something simple I am missing but cant put my thumb on it and I have spent well over 15 hours working on this.
As found on the following link:
Link to Answer
Try using the DCOUNTA function within Excel.
Although I'm also sure that you could use a pivot chart to provide the same outcome.
EDIT:
I am assuming you are starting with data like the following:
I then created the following table which you can extend to comply with you total data value. For example, you can add extra dates and products.:
The table is populated using a COUNTIFS function.
=COUNTIFS("DateRange",DateCriteria, "ProductRange", ProductCriteria, "GrizzlyRange", GrizzlyCriteria)
So in my table the formula looks like this but the cell references will obviously changes according to your spreadsheet (I used absolute references to make it easier to use the fill handle to copy the formula down:
=COUNTIFS($A:$A,$E4,$B:$B,$F$3,$C:$C,$F$2)
I next nestled this formula in to an IF statement and applied a conditional formatting to end up with the following:
So the formula for each of the cells is now:
=IF("OriginalFormula),"Yes","No")
Example of my 01/01/2015, 1.5 open value:
=IF(COUNTIFS($A:$A,$E4,$B:$B,$F$3,$C:$C,$F$2),"Yes","No")
BUT - You can change the "Yes" and "No" to "1" and "0" if you want to stick with numerical values.

average hourly traffic over the year

After hours of searching the web (including SO), I am requesting advice from the community. RRD seems to be the right tool for this, but I could not get a straight answer until now.
My question is : Is it possible to get RRD output a graph for the day, that averages data from the past year ?
In other words, I want the "view span" to be one day long, but the "data span" to extend over the last 12 months, so that for 6pm, the value will be computed as the average value of ALL previous traffic measured at 6pm last 12 months.
Any hints, or instructions welcomed!
There is no direct way to create such a graph, at least in theory it would be possible using multiple DEF lines together with the SHIFT operation to create such a chart ... you would have to use a program to create the necessary command line though