Counting a Time Range with COUNTIFS or SUMIFS

Josh08

New Member
Joined
Aug 23, 2019
Messages
6
Good Morning

I have an issue. I've been trying to create a formula to count the number of instances a particular time range appears in a column on a spreadsheet.

Column C contains manually entered times followed by AM or PM. One problem I've run into that may or may not be effecting the formula's I've tried is that the time formats are different in some columns.

Example
Data Type = General
12:17 PM

Example
Data Type = Custom
12:02:00 PM

I've tried many methods to make them all the same format. I would prefer the one with the General data type.

I tried converting the data type. Copying and pasting one with the format I wanted and change it in the cell, no luck.

=SUMIFS(A:A,">=6:00AM", A:A, "<3:00PM")

My desired results were not yielded from that formula. I've tried other formulas without the correct result either. I don't want to manually count over 350 times.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hello,

The main question is to determine if you are dealing with Text or dealing with Numbers ...
 
Upvote 0
Try this

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:38.02px;" /><col style="width:38.02px;" /><col style="width:136.87px;" /><col style="width:38.02px;" /><col style="width:76.04px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td > </td><td > </td><td >TIME</td><td > </td><td >Result</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td > </td><td > </td><td style="text-align:right; ">05:20:00 a.m.</td><td > </td><td style="text-align:right; ">6</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td > </td><td > </td><td style="background-color:#ffff00; text-align:right; ">06:45:00 a.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td > </td><td > </td><td style="background-color:#ffff00; text-align:right; ">08:10:00 a.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td > </td><td > </td><td style="background-color:#ffff00; text-align:right; ">09:35:00 a.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td > </td><td > </td><td style="background-color:#ffff00; text-align:right; ">11:00:00 a.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td > </td><td > </td><td style="background-color:#ffff00; text-align:right; ">12:25:00 p.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td > </td><td > </td><td style="background-color:#ffff00; text-align:right; ">01:50:00 p.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td > </td><td > </td><td style="text-align:right; ">03:15:00 p.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td > </td><td > </td><td style="text-align:right; ">04:40:00 p.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >11</td><td > </td><td > </td><td style="text-align:right; ">06:05:00 p.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >12</td><td > </td><td > </td><td style="text-align:right; ">07:30:00 p.m.</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >13</td><td > </td><td > </td><td style="text-align:right; ">08:55:00 p.m.</td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >E2</td><td >=COUNTIFS(C2:C19,">=06:00",C2:C19,"<=15:00")</td></tr></table></td></tr></table>
 
Upvote 0
The main question is to determine if you are dealing with Text or dealing with Numbers ...
You can quickly verify with the ISNUMBER function (as dates/times are stored in Excel as numbers).

So, if your time entry is in the cell A1, then enter this formula anywhere:
=ISNUMBER(A1)
If it returns TRUE, you have a valid date/time entry.
If it returns FALSE, you actually have a text entry.

In order to do date/time math on it, you will want it to be a valid date/time entry.
 
Upvote 0
You can quickly verify with the ISNUMBER function (as dates/times are stored in Excel as numbers).

So, if your time entry is in the cell A1, then enter this formula anywhere:
=ISNUMBER(A1)
If it returns TRUE, you have a valid date/time entry.
If it returns FALSE, you actually have a text entry.

In order to do date/time math on it, you will want it to be a valid date/time entry.

70 = True
380 = False
 
Upvote 0
I still didn't yield the appropriate count. Perhaps it has something to do with them not being numbers? See response below 70 are numbers, 380 aren't.
 
Upvote 0
I still didn't yield the appropriate count. Perhaps it has something to do with them not being numbers? See response below 70 are numbers, 380 aren't.

Are you saying that within your column ... certains cells are Numbers and some others are Text ...???
 
Upvote 0
Are you saying that within your column ... certains cells are Numbers and some others are Text ...???


I think I'm almost there. I was able to convert the values to numbers successfully. I now have a count of 370 numeric Time values in Column B of my spreadsheet.

I'm trying to capture Action Requests from 1-3rd shift. However with my COUNTIFS (3 statements) I'm short by 13 total. I have 357 not 370.

1st Shift (6:00AM - 3:00PM) - =COUNTIFS('Request Tracker'!C:C,">6:00",'Request Tracker'!C:C,"<15:00")
2nd Shift (3:00 PM - 10:00PM) - =COUNTIFS('Request Tracker'!C:C,">15:00",'Request Tracker'!C:C,"<22:00")
3rd Shift (10:00PM - 6:00AM) - =COUNTIFS('Request Tracker'!C:C,">22:00",'Request Tracker'!C:C,"<6:00")


1st Shift = 273
2nd Shift = 84
3rd Shift = 0
Total = 357
 
Upvote 0
Without your file .. difficult to guess what is in front of your eyes ...

Most probably for 2nd shift ... you should either >= or <=

and your third shift should be the Total minus both 1st and 2nd Shift ...
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,130
Members
453,021
Latest member
Justyna P

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