There are 3 time In & Out in hh:mm, in B:C,D:E & F:G.
formula in H23 =MOD(C23-B23,1)*24+MOD(E23-D23,1)*24+MOD(G23-F23,1)*24
formula in I23 =MOD(D23-C23,1)*C23+MOD(F23-E23,1)*24
Problem is if i keep the time nil without any data for IN or OUT the result is not specific.
Your formula was more or less ok, it just didn't include condition to ignore the incomplete information. The condition is simple, it makes part of the formula work only in case that both In and Out informations are filled.
Here's my formula for Prod Hrs:
=IF(AND(NOT(ISBLANK(C2)),NOT(ISBLANK(B2))),(C2-B2)*24,0)+IF(AND(NOT(ISBLANK(E2)),NOT(ISBLANK(D2))),(E2-D2)*24,0)+IF(AND(NOT(ISBLANK(G2)),NOT(ISBLANK(F2))),(G2-F2)*24,0)
And here's one for non-Prod Hrs:
=IF(AND(NOT(ISBLANK(D2)),NOT(ISBLANK(C2))),(D2-C2)*24,0)+IF(AND(NOT(ISBLANK(F2)),NOT(ISBLANK(E2))),(F2-E2)*24,0)
This worked! =MAX(0,IF(AND(NOT(ISBLANK(D24)),NOT(ISBLANK(C24))),(D24-C24)*24,0)+IF(AND(NOT(ISBLANK(F24)),NOT(ISBLANK(E24))),(F24-E24)*24,0)-1)
Related
I am trying to get the averages of a column that meet certain criteria into a single cell.
The following formula works: =AVERAGEIFS(tblData[Sys],tblData[Time],">=12:00 PM",tblData[Time],"<6:00 PM") but when I adjust the time values to: =AVERAGEIFS(tblData[Sys],tblData[Time],">=6:00 PM",tblData[Time],"<4:00 AM") I get an error. I'm guessing it's because the time range goes into the next day.
Is there a better function to use or a workaround?
This formula seems to work for you scenario. It checks for the possibility that the end time is before the start time (but on the next day) and changes the logic accordingly:
=AVERAGE(
IF(
IF(tmStart>=tmEnd,
(tblData[Time]>=tmStart)+(tblData[Time]<=tmEnd),
(tblData[Time]>=tmStart)*(tblData[Time]<=tmEnd))
=1,tblData[Sys],""))
It's important to understand this function does, and the underlying intentions are - I elaborate in the what follows, proffer a workable solution, provide a reconciliation, as well as a link to the workbook with screenshot below.
You will need to specify # days spanned - even the scenario that 'worked' for you (i.e.. =AVERAGEIFS(tblData[Sys],tblData[Time],">=12:00 PM",tblData[Time],"<6:00 PM") could, in theory, span 2 (or more) days. The fact that this 'works' (doesn't return #DIV/0!) is that the 'intersection' of conditions is an non-empty set (i.e. {12pm-5pm}).
As I say, if this was intended to be ">=12:00" from day 1 through to "<6pm" the following, there is no way of determining whether this is indeed the case by simply 'comparing the times' (e.g. 12pmvs 6pm).
Screenshot/here refer::
=IF($I$5="Y",(SUM(1*($C$5:$C$28*(($D$5:$D$28>=$J$3)+1*($D$5:$D$28<$K$3)))))/SUM((($D$5:$D$28>=$J$3)+1*($D$5:$D$28<$K$3))),IFERROR(AVERAGEIFS(C5:C28,D5:D28,">="&J3,D5:D28,"<"&K3),"times don't intersect! "))
where: I5 = 'Y' or 'N' (i.e. multiple days'). When scenario B is selected, with multiple days = 'Y', outcome = 12.9 which reconciles to a manual calculation.
I have to determine per specialty the total percentage of surgeries that started outside the regular working hours or in weekends.
This is what I have so far:
=COUNTIFS(Table1[Start surgery];">17:00")+COUNTIFS(Table1[Start surgery];"<09:00")+COUNTIFS(Table1[Surgery date];"MOD(WEEKDAY(cell), 7) <2")
The first 2 countifs work, but I'm not able to count the weekend days. And a second thing is that its possible for excel to count some surgeries twice, because a surgery can be after 17:00 and in the weekend, but that has to count as one.
Who can help me:)?
Since the first part of your formula is working for time I just modified the last part of your formula...
=COUNTIFS(Table1[Start surgery];">17:00")+COUNTIFS(Table1[Start surgery];"<09:00")+SUMPRODUCT((WEEKDAY(Table1[Surgery date])=1)+(WEEKDAY(Table1[Surgery date])=7)
Where 1 and 7 are equivalent to Saturday and Sunday.
The current problem with the formula above is that surgery time after 1700 and before 0900 on the weekend are counted twice!
To rectify this all conditions could be moved inside the sumproduct as one potential solution and you would wind up with:
=SUMPRODUCT((WEEKDAY(Table1[Surgery Date])=1)+(WEEKDAY(Table1[Surgery Date])=7)+(WEEKDAY(Table1[Surgery Date])=MEDIAN(WEEKDAY(Table1[Surgery Date]),2,6))*(Table1[Start surgery]<"09:00")+(WEEKDAY(Table1[Surgery Date])=MEDIAN(WEEKDAY(Table1[Surgery Date]),2,6))*(Table1[Start surgery]>"17:00"))
Now the bracket count may be off in there as I was not using excel at the time. The other potential issue we may have is with time. is your time n the time column text or a number formatted to display as time? This may involve modifying are time comparison to a different format, but the formula itself should remain the same.
Basic think here is we put each condition inside the sumproduct. The condition will evaluate to either TRUE or FALSE. If the condition undergoes a math operation it will be turned into 1 for TRUE and 0 for FALSE. + act like OR statements, and * act like AND statement.
I need to calculate the total hours and minutes between two dates mentioned in excel. i.e.,
Start date: 02-Sep-2013 02:03:00 AM
End Date: 04-Sep-2013 02:04:00 AM
The answer should be 48:01 h:mm.
Need to consider holidays also, like if 03-Sep-2013 is holiday, then
The answer should be 24:01 h:mm.
There are no business hours. It should consider 24 hours. Please help me on this.
a simple subtraction will get you the value you want: subtract one date/time from the other, and then subtract the number of holiday dates that fall between the two dates.
the trick is to format the result cell as [h]:mm (this format works for up to 9999 hours)
Here's an example:
Hours = ((End_Date+End_Time)-(Start_Date+Start_Time))*24
For more details please refer the below link
Excel
Another Formula with example
Cell A1: 2/15/2012 10:00:00 AM
Cell B1: 2/18/2012 08:00:00 PM
What is the elapsed time between both dates (in hours)?
You can get the answer by using the below formula in cell
C1:= INT(B1-A1)*24+(((B1-A1)-INT(B1-A1))/0.04166666)
The problem with many of the example answers given is definitional. If you are looking for elapsed time finer than days in significant digits the "B2-B1" answer given is incorrect if the end time is earlier in the day than the start time.
Depending on what I am trying to extract I use variations of the following formula to get a more precise "elapsed time". Depending on why a person lands on this answer the difference in result can make a difference.
=ROUNDDOWN(B3-B2,0) & " Days "
& ROUNDDOWN(MOD(B3-B2,1)*24,0) & " hours "
& TEXT(MOD(MOD(B3-B2,1)*24,1)*60,"#0") & " Mins"
(formatted for easier reading)
The image below shows the results of the different answers proposed. I am not saying the other answers are wrong just that they may not be precise enough depending on the purpose of the answer seeker.
I have two time:
9:29:00 AM (B2)
6:16:00 PM (C2)
I want to get the hh:mm (hours and minutes) between those two times. I tried the following function:
=TEXT(B2-C2,"h:mm")
But I get a #VALUE! error.
I formatted the two time cells as TIME format (*h:mm:ss am:pm) and result cell also as TIME format (hh:mm)
Is that the right way round? Try
=C2-B2
You don't need TEXT function
I believe your #VALUE error is due to your order of subtraction, but I can't be sure without knowing which of those times is B2 and which is C2, and I can't quite comment on your question yet, so an answer it is!
Times in excel are stored as doubles which increment by 1 each day; 0.5 is 12 hours etc.
Best thing to do is use =TEXT(B2-C2,"HH:MM")
This will format B2-C2 (a decimal number) as a time interval.
Of course the contents of B2 and C2 must be numeric; see my VALUE function in the comments.
As barry houdini mentioned back in 2013, I also ran into the error of subtracting giving a negative number, and excel just throws an error. No other response on the internet gave me good results. Although my method is longer, it always works with times in hh:mm:ss AM/PM. Just change the text format part of the formula for whatever you have. My data was:
11:15:45 PM 1:41:20 AM
I converted it to military time for ease with
=TEXT(A2, "hh:mm:ss")
Data was now:
23:15:45 01:41:20
I made another column, let's call it C, that just subtracts the second time from the first time,
=B2-A2
I next used an IF statement on this column, so that if the absolute value of the difference was the same as the number (a positive), I'd use
TEXT(B2-A2,"hh:mm:ss")
which just subtracts the later time from the earlier time. But...
If the absolute value of the difference was not the same, e.g. error-ville with a lot of hashes ##########, I use:
TEXT(24-(A10-B10),"hh:mm:ss")
Altogether, we have one more column, which finally spits out the correct hour difference. This column is predicated on columns A, B, and our error-prone difference column C:
=IF(C2=ABS(C2),TEXT(B2-A2,"hh:mm:ss"),TEXT(24-(A2-B2),"hh:mm:ss"))
this is the most ridiculous thing I have ever done. It's been years and such a simple case, never solved by Excel.
I have a little problem with Excel. I nead to make a function that checks if a person is older that 19.
I checked for a function online but it does not work the way it should.
First I have a date in a unusual format 14 10 2012 , I used =SUBSTITUTE(J2, " ", ".")
to get 14.10.2012
after that I use a formula
=IF(P2<DATE(DAY(NOW()),MONTH(NOW()),YEAR(NOW())),"Older than
19","Too young")
but no mater what I do it does not work correctly. It shows the same resolute if the number is bigger or smaller
why is =DATE(DAY(TODAY()),MONTH(TODAY()),YEAR(TODAY())) showing me 3.4.1920 ?
I think that you might have the parameters around the wrong way. If I put:
=DATE(DAY(TODAY()),MONTH(TODAY()),YEAR(TODAY()))
into Excel, I also get 3.4.1920.
If, however, I enter:
=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))
I get 14.10.2012 - today's date!
======
Just as a followup, I suspect that you are trying to compare today's date with a date of birth to determine someone's age and whether they are over 19?
Try this:
Enter the formula above into a cell (hidden if you like) - lets call it A1
Have the person's date of birth entered into another cell - lets say A2
Enter the formula =A1-A2 into a third cell (A3). This gives you their age in days.
Another formula - this time =A3/365.25 (that is, their age in days divided by the number of days in a year). Let's say that's A4
It's then a simple IF statement =IF(A4>19,"Over 19","Too young")
Hope that helps :-)
=IF(YEAR(NOW())-RIGHT(J2,4)>55,"starejsi",IF(YEAR(NOW())-RIGHT(J2,4)=55,
IF(MONTH(NOW())-LEFT(RIGHT(J2,7),2)>0,"older",
IF(MONTH(NOW())-LEFT(RIGHT(J2,7),2)=0,
IF(DAY(NOW())-LEFT(J2,FIND(" ",J2,1))>=0,"older","younger"),"younger")),"younger"))
finally i have done it. this is the code