How can I categorize time?

JenTaylor

New Member
Joined
Jan 14, 2004
Messages
2
Greetings,

Perhaps a similar question has been posted, but I cannot find it...I apologize if I am replicating a question.

I have a spreadsheet that lists incidents by date and time. I need to create a summary table of the data that indicates the number of incidents that occurred between 00:00-02:59, 03:00-05:59, 06:00-0859, etc.

Times are formated to view HH:MM, but are stored as hh:mm:ss AM/PM, so I am not having any luck with typing in simple IF statements. I tried formatting the time to text or numbers, but cannot retain the leading zeros. There must be a way to do this, but I am baffled. Any help would be much appreciated! :help:

Thanks in advance!!

-Jen
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi - welcome to the board

How about this;

Code:
=IF(AND(HOUR(B2)>=0,HOUR(B2)<3),TRUE,FALSE)
 
Upvote 0
JenTaylor said:
Greetings,

I have a spreadsheet that lists incidents by date and time. I need to create a summary table of the data that indicates the number of incidents that occurred between 00:00-02:59, 03:00-05:59, 06:00-0859, etc.

Times are formated to view HH:MM, but are stored as hh:mm:ss AM/PM, so I am not having any luck with typing in simple IF statements. I tried formatting the time to text or numbers, but cannot retain the leading zeros. There must be a way to do this, but I am baffled. Any help would be much appreciated! :help:

Thanks in advance!!

-Jen

Times are displayed as you indicated but this is formatting. The actual entry is a decimal part of a day. 1.0 is 24 hours, .5 is 12 hours or noon. You must use these fractional parts of a day in your formula i.e

=COUNTIF(A12:A20,"<.5") would count all times before noon.

Post again if this is not clear enough
 
Upvote 0
Jen,

Use a coercer for times in your formula, as shown below. What are you trying to count between times. Care to post a sample of your data and expected results.
Book1
ABCD
110:29
Sheet1
 
Upvote 0
Thank you all for your responses! :beerchug:

I tried using =COUNTIF(A12:A20,"<0.5") and it seems to work. The only thing I had to add to the formula is a SUM statement to subtract the incidents that have already been counted from the current total...i.e. =(COUNTIF(A12:A20,"<0.5"))-SUM(B2:B6).

I am unclear, however, how this works when the time is 00:00. Is it stored as 0.0 or 1.0? Not many incidents occur right at midnight, but there are over forty in a quick count that I did through less than half of my data.

I cannot post a sample of my data as it is sensitive, but here is an example of my problem: My categories are

00:00-02:59
03:00-05:59
.
.
18:00-20:59
21:00-23:59

If the incidents that occurred at midnight are included in the last category, I have an error of x number of incidents in two categories. Is there a way around this short of actually counting the number of occurrences of 00:00 in my data?

-Jen
 
Upvote 0
Hi Jen:

You may want to try ...
y040114h1a.xls
ABCD
1soucetimeFrameincidents
212:43:00AM00:00-02:595
31:11:00AM03:00-05:597
41:39:00AM06:00-08:594
52:07:00AM
62:35:00AM
73:03:00AM
83:31:00AM
93:59:00AM
104:27:00AM
114:55:00AM
125:23:00AM
135:51:00AM
146:19:00AM
156:47:00AM
167:15:00AM
177:43:00AM
Sheet5


The formula in cell C2 is ...

=SUMPRODUCT(($A$2:$A$17>=(--LEFT($C2,4)))*(($A$2:$A$17<=(--RIGHT($C2,4)))))
 
Upvote 0

Forum statistics

Threads
1,222,905
Messages
6,168,948
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