Time value that should be 24:00 displays as 0:00
Format your C8
and C9
as Custom format [h]:mm
Then, put on C9
this formula =1-C8
instead of =24-C8
Putting 24 on your C9
will break your formula if there is a value on E48
What you have now is working for the wrong reason.
Obviously, E48
is a number of hours,
so C8
, which contains =E48/24
, is a number of days.
If E48
is between 0 and 24, then C8
will be between 0 and 1,
expressing a fraction of a day.
This corresponds to the way Excel’s date/time storage works —
a date/time is stored as the number of days
(including a fraction of a day, as necessary) since midnight, January 1, 1900.
That’s why C8
is correctly displaying
as the number of hours and minutes
corresponding to the number of hours in E48
.
But, if E48
is between 0 and 24, and C8
is between 0 and 1,
then 24-C8
is a number between 23.0 and 24.0.
Specifically, if (as in your example) E48
is 15.5,
then C8
is 0.645833333 and C9
is 23.35416667.
Since C8
expresses a number of days,
the 24
is interpreted as a number of days.
If you change the format of C8
and C9
to a custom format of d "days and" h:mm
,
you will see that, for E48
= 15.5,
C8
will be 0 days and 15:30
and C9
will be 23 days and 8:30
.
So, two things:
- Since
C8
is a number of days, you wantC9
to be=1-C8
— computing the rest of the day, and not looking at a 24 day period. -
In an Excel cell display format for a date/time value, the
h
(andhh
),mm
,ss
, andAM/PM
tokens look only at the fractional part of the value — i.e., the fraction of a day, which corresponds to a time of day. (Note the way the 23.35416667 value is displayed as23 days and 8:30
; the8:30
corresponds to the 0.35416667 fraction.)A blank
E48
, of course, is interpreted as a value of 0, and will causeC8
to evaluate to 0. WithC9
set to=1-C8
, it will evaluate to 1. If you still haveC9
formatted asd "days and" h:mm
, you will see that it displays as1 days and 0:00
, which, of course, is equivalent to 24 hours. To get it to display as24:00
, you need to use[h]
in the format instead of just plainh
; i.e., use a format of[h]:mm
instead of just plainh:mm
. The[h]
token looks at the entire value in the cell (not just the fractional part) and will display hours ≥24.