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

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")

Related

Google Sheets - If worked past midnight

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)

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.

Optimizing / speeding up calculation time in Google Sheets

I have asked a few questions related to this personal project of mine already on this platform, and this should be the last one since I am so close to finishing. Below is the link to a mock example spreadsheet I've created, which mimics what my actual project does but it contains less sensitive information and is also smaller in size.
Mock Spreadsheet
Basic rundown of the spreadsheet:
Pulls data from a master schedule which is controlled/edited by another party into the Master Schedule tab.
In the columns adjacent to the imported data, an array formula expands the master schedule by classroom in case some of the time slots designate multiple rooms. Additional formulas adjust the date, start time, and end time to be capped within the current day's 24-hour period. The start time of each class is also made to be an hour earlier.
In the Room Schedule tab, an hourly calendar is created based on the room number in the first column, and only corresponds to the current day.
I have tested the spreadsheet extensively with multiple scenarios, and I'm happy with how everything works except for the calculation time. I figured the two volatile functions I use would take some processing time just by themselves, and I certainly didn't expect this to be lightning-fast especially without using a script, but the project that I am actually implementing this method for is much larger and takes a very long time to update. The purpose of this spreadsheet is to allow users to find an open room and "reserve" it by clicking the checkbox next to it (which will consequently color the entire row red) allowing everyone else to know that it is now taken.
I'd like to know if there is any way to optimize / speed up my spreadsheet, or to not update it every time a checkbox is clicked and instead update it "manually", similar to what OP is asking here. I am not familiar with Apps Script nor am I well-versed in writing code overall, but I am willing to learn - I just need a push in the right direction since I am going into this blind. I know the number of formulas in the Room Schedule tab is probably working against me yet I am so close to what I wanted the final product to be, so any help or insight is greatly appreciated!
Feel free to ask any questions if I didn't explain this well enough.
to speed up things you should avoid usage of the same formulae per each row and make use of arrayformulas. for example:
=IF(AND(TEXT(K3,"m/d")<>$A$1,(M3-L3)<0),K3+1,K3+0)
=ARRAYFORMULA(IF(K3:K<>"",
IF((TEXT(K3:K, "m/d")<>$A$1)*((M3:M-L3:L)<0), K3:K+1, K3:K+0), ))
=IF(AND(TEXT(K3,"m/d")=$A$1,(M3-L3)<0),TIMEVALUE("11:59:59 PM"),M3+0)
=ARRAYFORMULA(IF(K3:K<>"",
IF((TEXT(K3,"m/d")=$A$1)*((M3-L3)<0), TIMEVALUE("11:59:59 PM"), M3:M+0), ))

How to keep track of the index in an array

I need to create a stats sheet that records the amount of touchdowns performed by a certain team. I have it working for the first round when it records all 8 teams, however in the semifinals since only 4 teams make it, it does not keep track of what index the winning teams were on and just couts the stats in a regular order from 0 - 4. Ive been thinking for a couple days now on how I could possibly overcome this but I havent been able to find a solution yet.
the stats table that is outputted
Please let me know if i can contribute anymore information to make my question less vague and easier for you to understand. I appreciate all the help, thank you.

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