I need to average time in Numbers, but once past midnight, it’s not accurate. How do I fix this?

Hi,

what I am trying to do is collect time of ending something and avarage it. But when there is a time that pass midnight, it has other date and the average time is not correct. Is there a way to solve this?


[Re-Titled by Moderator]

MacBook Air 13″, macOS 12.6

Posted on Apr 15, 2024 10:54 PM

Reply
Question marked as Best reply

Posted on Apr 19, 2024 7:35 AM

The error triangles tell you what they think is wrong. If it is a syntax error it is most likely because you are someplace that uses the comma as the decimal separator. If that is the case, the parameters in a function need to be separated by semicolons, not commas, and the number 0.5 in the formula needs to be 0,5


=IF(A="";"";TIMEVALUE(A+0,5))


10 replies
Question marked as Best reply

Apr 19, 2024 7:35 AM in response to YagamiAdachi

The error triangles tell you what they think is wrong. If it is a syntax error it is most likely because you are someplace that uses the comma as the decimal separator. If that is the case, the parameters in a function need to be separated by semicolons, not commas, and the number 0.5 in the formula needs to be 0,5


=IF(A="";"";TIMEVALUE(A+0,5))


Apr 16, 2024 2:46 AM in response to YagamiAdachi

Hi YagamiAdachi,


I am not sure of your overall aim, but perhaps the TIMEVALUE function will work for you. TIMEVALUE ignores the date and shows the decimal fraction of a day. Click in a cell and type = to see the Function Browser:



Here we go, with Date & Time formatted as YYYY-MM-DD (to make the Date more "International") and 24 hour time:



Formula in B2 (and fill down) is TIMEVALUE(A2)

Formula in Footer Cell B7 is AVERAGE(B)


I may not have answered your question. Please call back with more details.

Ian.

Apr 16, 2024 6:10 AM in response to YagamiAdachi

This isn't a simple average, that's for sure.

22:00 and 22:02 averages to 22:01

23:00 and 1:00 "averages" to 0:00

22:59 and 1:00 "averages" to 11:59:30


You also have to strip the dates off to do any average that will make sense. 12:00AM yesterday averaged with 12:00AM today is not "12:00AM", it is halfway between the two date&time values = 12:00PM yesterday. TIMEVALUE strips the dates and gives a decimal number for the time of day. 0 = midnight, 0.5 = 12PM (halfway through the day), and so on up to just about 1.0 and then it becomes 0 again.


Because your bedtimes cross midnight, a simple average of the times of day won't work because you are averaging numbers that are close to 1 (near the end of the day) with numbers that are close to 0 (the beginning of the day) and the resulting average will be sometime in the middle of the day (0.5). We need to shift the clock so your times don't cross that 0 boundary. Shifting forward by half a day should work. Your late night bedtimes will move to just before noon the next day and your early morning bedtimes will be just after noon. Then we shift it back after doing the average.


Column B formula =IF(A="","",TIMEVALUE(A+0.5))

Copy/paste it to all the rows in the column


The average =TODAY()+AVERAGE(B)−0.5



Apr 16, 2024 4:15 AM in response to YagamiAdachi

I want to track my sleeping and see what time I go to bed on average. For example yesterday I went to sleep at 22:00 and today at 22:02. The average is 22:01. But in my case, if I go to bed after midnight, it already has another date and does not make sense.


I also tried TIME(HOUR(A2);MINUTE(A2);SECOND(A2)) and then the AVERAGE formula but again if i pass the midnight it does not work.


I need to average time in Numbers, but once past midnight, it’s not accurate. How do I fix this?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.