How to average times that cross midnight?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,532
Office Version
  1. 365
Platform
  1. Windows
I have several sheets with columns of just times (no dates). I want to calculate the Max, Min, and Ave times. Most of these times are between 9pm and midnight as in column D. A few are at or after midnight as in Column F. If none of the times are later than 11:59 PM, then the calculations work. If any are at or after midnight, the calculations are wrong.

1610782753943.png

A solution I came up with is in Column H. I move the times back half a day. If they are before midnight, I subtract 0.5. If they are at or after midnight, I add 0.6. Now they are in the same relative position to each other, but around noon, rather than midnight. Then, when I do the calculations, I add the half day back in and everything is correct.

I know this is kludgy and it depends on the times all being close to midnight.

Is there a better way?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If start time and end time are within a 24h window, you can use =MOD(Endtime - Starttime, 1).
 
Upvote 0
If start time and end time are within a 24h window, you can use =MOD(Endtime - Starttime, 1).
There is only one time. It's for when a blood glucose reading was taken. At the end of a recording period, I want to calculate the earliest, latest, and average time when those reading were taken.
 
Upvote 0
You should Input Date & time then Take Average for them.
 
Upvote 0
You should Input Date & time then Take Average for them.
I am not averaging the date + time -- just the time. These readings are all taken on different days. If I averaged the full time stamp (date + time), I would get a time stamp somewhere in the middle of the range. I want the average time of day when the readings are taken. If they are 9pm on Monday, 10pm pm Tuesday, and 11pm on Thursday (no reading on Wednesday), I want the average to be 10pm, not sometime 6 am on Wednesday, which is what I'd get if I averaged the time stamps (date + time).

1610786694420.png

This is not the average I need.
 
Upvote 0
Then just take =MOD(YourTime,1) and MIN, MAX, AVERAGE those.
 
Upvote 0
Then just take =MOD(YourTime,1) and MIN, MAX, AVERAGE those.
Unless there is something I don't understand, taking the Mod,1 of my time stamps will be a NOP. By definition, times are [0,1) -- fractions of a day.

1610787668020.png
 
Upvote 0
Try this for Minimum & Maximun:
Excel Formula:
=MINIFS(D6:D9,D6:D9,">"&0.5)
AND
Excel Formula:
=IF(MAXIFS(D6:D9,D6:D9,"<="&0.5)=0,MAX(D6:D9),MAXIFS(D6:D9,D6:D9,"<="&0.5))
 
Upvote 0
Solution
Try this :
Excel Formula:
=Average(D6:D9)+iferror(1/Countif(D6:D9,"<" & 0.5),0)
Wow!!! That works. That IfError function is new to me. It will come in handy. Thanks.

I'll have to study why the CountIf works.

This same formula does not work for Min & Max.
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,888
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top