Time Issue at Midnight

KuraiChikara

Board Regular
Joined
Nov 16, 2016
Messages
111
Office Version
  1. 2013
Platform
  1. Windows
I have an issue with a COUNTIF formula once a schedule goes to midnight and after.
In column A I have four times; 21:00, 22:00, 23:00 and Midnight.

The first formula only looks at A2-A4; omitting midnight: Count, If A2 through A4 is greater than or equal to 9:00 PM, the result is 3; this is fine.
=COUNTIF(A2:A4,">=21:00")

However, in the sense of working schedules, not a standard day, someone who works 4pm to 1am is considered to work later than someone who works 1pm to 10pm, so from a verbiage standpoint you can say 1am is later than 10pm but Excel doesnt like that.

In the second formula, I'm including midnight cell A5, but it doesnt count midnight because midnight in technical terms is not "Greater" than 9pm; it's earlier and I don't know how to represent that.

=COUNTIF(A2:A5,">=21:00")


TimeFormula 1Formula 2
21:0033 (my goal is 4)
22:00
23:00
00:00

<tbody>
</tbody>
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I'm not sure exactly what you want to do, but a quick and dirty way to work round this is to use 23:59 instead of 00:00.

This might or might not work for you, depending on what you want to do exactly.
 
Upvote 0
However, in the sense of working schedules, not a standard day, someone who works 4pm to 1am is considered to work later than someone who works 1pm to 10pm, so from a verbiage standpoint you can say 1am is later than 10pm but Excel doesnt like that.
What you are describing is a period over multiple days. So I don't think you can do this strictly with time. I think you need a day component too. Then you should be able to do what you want.

Note that Excel actually stores all time values with date components. You just format it to "hide" the date piece.
Excel stores dates/times as the number of days since 1/0/1900 (enter any date, and change the format to "General" and you will see this).
Dates are just whole numbers, and times are fractions of one day.

So if you enter today's date and a time like this:
5/30/2019 6:00 AM
and convert the cell format to General, you will see it as Excel does:
43615.25
 
Last edited:
Upvote 0
You actually helped remind me with an older process that I used to use. Japan extends the 24 hour clock further in some situations and I forgot that Excel interprets this; IE 23:00=11pm, 24:00=midnight, 25:00=1:00am, 26:00=2:00am etc. This method works. Using my formula in example 2, if I change midnight from 00:00 to 24:00 it works like a charm.
 
Upvote 0

Forum statistics

Threads
1,215,351
Messages
6,124,445
Members
449,160
Latest member
nikijon

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