# Question: How many occurences in date range?

D

#### dlowrey

Good afternoon

Col A has a list of dates and times. The data looks like this:
08/09/09 08:12
08/09/09 09:15
08/10/09 07:59.. etc.

Each date/time represents one transaction.
We need to count the number of transactions occurring on a each day between
two times. For example, on 8/09/09 between 8:00 and 9:59 the answer would be
2.

Can you give me some ideas about how to approach this problem? We don't
want to script this, but will use a separate cell on a sheet for each date
and time range.

-DL

P

#### Per Jessen

Hi

First you need to split and times using 'Text To Columns' with 'space'
as delimitter.

Then use use this formula to calculate occurences in range:

=SUMPRODUCT(--(A1:A3=DATEVALUE("08-09-2009")),--(B1:B3>=TIMEVALUE
("08:00")),--(B1:B3<TIMEVALUE("10:00")))

Regards,
Per

J

#### JoeU2004

dlowrey said:
We need to count the number of transactions occurring on a each
day between two times.

Suppose your data is in column A of Sheet1, in column A and column B on
Sheet2, you have the list of dates and time ranges to be counted.

8/9/09 8:00 8/9/09 10:00
8/9/09 9:00 8/9/09 12:00
....etc...

Then in column C of Sheet2, you would enter the following formula and copy
down:

=sumproduct( (A1 <= Sheet1!\$A\$1:\$A\$100) * (Sheet1!\$A\$1:\$A\$100 < B1) )

Note: Generally, it is better test for "less than" some upper time limit
than to test for "less or equal to" some time minus one minute. This has to
do with the internal form in which Excel stores date/time information.
However, if you enter date/time information manually, it is not a problem,
and "less than or equal" would work just as well.

----- original message -----

D

#### dlowrey

I think you all are saying that I need to first transform a date-time value
stored in a cell into into 2 text values in two additional columns, one for
date, one for time.

This seems a little strange. If the date/time in a cell is a unique number
(I understand that dates are actually stored as integers incremented by
seconds), then I would think that there must be some way to compare them
directly.

-DL

J

#### JoeU2004

dlowrey said:
I think you all are saying that I need to first transform a date-time
value
stored in a cell into into 2 text values in two additional columns, one
for
date, one for time.

This seems a little strange.

I concur. I, for one, did __not__ say you need to first make a
transformation.

I would think that there must be some way to compare them
directly.

My formula does exactly that. I think the formulas posted by "p45cal" are
similar.

----- original message -----