Count by time block in Date/Time Group column

admvlad

New Member
Joined
Apr 29, 2024
Messages
7
Office Version
  1. 2021
Platform
  1. Windows
I have a column with a date/time. I need to know how many instances occur by time block. The blocks are 0000-0400, 0400-1200, 1200-2000 and 2000-0000. I have tried =COUNTIFS(D:D,">=00:00:00",D:D,"<=04:00:00") but it returns nothing. That does work in another sheet that only has time in the column. The cells show this format:

19/2148
20/1439
22/1214

But the actual data is in this format: 4/19/2024 21:48:00
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
MrExcelPlayground23.xlsx
ABCD
19/12/2024 9:050000-40004
29/12/2024 22:174000-120010
39/12/2024 22:221200-20004
49/13/2024 1:102000-00008
59/13/2024 4:28
69/13/2024 12:16
79/14/2024 3:37
89/14/2024 21:17
99/15/2024 5:27
109/15/2024 9:57
119/16/2024 7:10
129/17/2024 6:07
139/17/2024 12:57
149/18/2024 11:43
159/18/2024 19:46
169/18/2024 22:26
179/19/2024 13:27
189/20/2024 2:13
199/20/2024 22:11
209/21/2024 2:00
219/21/2024 22:40
229/22/2024 10:25
239/23/2024 5:56
249/23/2024 20:23
259/24/2024 4:01
269/24/2024 20:32
Sheet20
Cell Formulas
RangeFormula
D1D1=ROWS(FILTER(A1:A26,MOD(A1:A26,1)<4/24))
D2D2=ROWS(FILTER(A1:A26,(MOD(A1:A26,1)>=4/24)*(MOD(A1:A26,1)<0.5)))
D3D3=ROWS(FILTER(A1:A26,(MOD(A1:A26,1)>=0.5)*(MOD(A1:A26,1)<20/24)))
D4D4=ROWS(FILTER(A1:A26,MOD(A1:A26,1)>=20/24))
 
Upvote 0
1) Count instances between 00:00 and 04:00:
=SUMPRODUCT(--(MOD(D2:D1000,1)>=TIMEVALUE("00:00:00")), --(MOD(D2:D1000,1)<TIMEVALUE("04:00:00")))

2) Count instances between 04:00 and 12:00:
=SUMPRODUCT(--(MOD(D2:D1000,1)>=TIMEVALUE("04:00:00")), --(MOD(D2:D1000,1)<TIMEVALUE("12:00:00")))

3) Count instances between 12:00 and 20:00:
=SUMPRODUCT(--(MOD(D2:D1000,1)>=TIMEVALUE("12:00:00")), --(MOD(D2:D1000,1)<TIMEVALUE("20:00:00")))

4) Count instances between 20:00 and 00:00 (crossing midnight):
=SUMPRODUCT(--( (MOD(D2:D1000,1)>=TIMEVALUE("20:00:00")) + (MOD(D2:D1000,1)<TIMEVALUE("00:00:00")) >0))

Note: Adjust D2:D1000 to match the range of your data.
 
Upvote 0
Thank you!

That works great for the most part. The only issue I am having is with the D1 formula, it seems to be counting all blank cells as well. Is there a way to get it to ignore a cell if it has nothing in it? The other 3 are completely accurate.
 
Upvote 0
=ROWS(FILTER(A1:A27,(MOD(A1:A27,1)<4/24)*(A1:A27<>"")))
 
Upvote 0
Solution

Forum statistics

Threads
1,222,905
Messages
6,168,949
Members
452,227
Latest member
sam1121

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