Count Cell Dates Between Specific Period of Time

iherndon

Board Regular
Joined
May 24, 2009
Messages
102
I have a list of dates in a single column that I need to determine the total count of cells with a date that's within a specific time frame.

Example
5/2/2011 9:05
5/2/2011 8:50
5/2/2011 1:00
5/2/2011 7:00
5/1/2011 22:10
5/1/2011 8:59
5/2/2011 6:59
5/1/2011 9:00
5/2/2011 12:00
5/2/2011 19:45

If I'm looking to count how many of the above 10 cells are between 7:00AM and 8:59AM, I should come to a total of 3.

5/2/2011 7:00
5/2/2011 8:50
5/1/2011 8:59

P.S. I'm using Excel 2007

Thanks for any help you can offer!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Code:
=COUNTIF(A1:A10,">"&D4)-COUNTIF(A1:A10,"<"&D6)

where A1:A10 is you date list
D4 and D6 is your date Range that you define.

See if the above formula helps!!
 
Upvote 0
Wow quick reply, thanks!

I think I might be inputting D4 and D5 incorrectly Since I'm only looking at the times of day, not a specific day or period of days.

I put "7:00AM" in D4 and '8:59AM" and the result returned was 0

After taking out the AM characters my result was 10 of 10 instead of 3. Is there a certain formatting I should use?
 
Upvote 0
When you input 7:00 AM in the cell the value of the cell would be 00/01/1900 7:00:00 AM. So my formula has to include date for the result.
 
Upvote 0
When you input 7:00 AM in the cell the value of the cell would be 00/01/1900 7:00:00 AM. So my formula has to include date for the result.

Ah, so I wouldn't be able to use it for more than one day's worth of data because it's limited to including a date with the time? From one moment to the next I could be looking up just yesterday, last week, last month, random date ranges, but what's always the same is just the hours that I'm looking for a count on; basically just hoping to have a list of the dates and times and get a count on them for the ones within a specific hour period regardless of the date.
 
Upvote 0
Do one thing add one more column to your table and add this formula

=VALUE(TEXT(A2,"HH:MM:SS AM/PM"))

it will convert all your time with date to pure time with date as 0.
Then the above formula would work for you with this new table.
 
Upvote 0
Do one thing add one more column to your table and add this formula

=VALUE(TEXT(A2,"HH:MM:SS AM/PM"))

it will convert all your time with date to pure time with date as 0.
Then the above formula would work for you with this new table.

Ah man that's so simple! Thanks! Lol I made a macro that did F2 ->Ctrl + Shift + Right Arrow -> Delete -> Enter and repeat. Then had it cycle through thousands of cells lmao.
 
Upvote 0
Ah man that's so simple! Thanks! Lol I made a macro that did F2 ->Ctrl + Shift + Right Arrow -> Delete -> Enter and repeat. Then had it cycle through thousands of cells lmao.

I don't know why but I avoid using SendKey command.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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