Counting unique Dates without the time affecting the outcome

zanzi

New Member
Joined
May 12, 2004
Messages
2
I am trying to count the number of days worked in a list the has different activities listed at different times in the day. Because of the different times in a single day I am having trouble getting a count of the days only.

I used a formula from another posting ......

=SUM(IF(LEN(B29:B100),1/COUNTIF(B29:B100,B29:B100)))

but it treats each date and time as a unique entity. I need to just count the days but am stuck with data that also has times attached. Is there any way around this?

example

4/12/04 12:00 AM
4/12/04 12:00 AM
4/13/04 12:00 AM
4/13/04 5:57 PM
4/13/04 8:37 PM
4/14/04 12:00 AM
4/14/04 6:26 PM
4/14/04 6:28 PM
4/14/04 6:28 PM
4/15/04 12:00 AM
4/15/04 7:29 PM
4/15/04 7:29 PM
4/16/04 12:00 AM
4/16/04 8:37 PM
4/17/04 12:00 AM
4/17/04 3:52 PM
 
Re: Counting unique Dates without the time affecting the out

jlu21 said:
Only date values. (mm/dd/yyyy)

The data can be sorted in ascending value, but I am trying to figure out a solution flexible enough to accomodate it if one or two date records are out of order.

I kinda have a rough solution, combining the code provided above, and also using the MATCH function to determine the first and last row ids of the range, and then concatenating the fields to create a range, but it's not very clean, and I'm sure there are situations where it may not be accurate. (ie. when the data is not in ascending order) :confused:
Book15
ABCDE
120
21/4/2004Ifsortedinascendingorder
31/15/20042/15/200462/16/2004
41/28/20043/16/2004123/15/2004
52/3/20044
62/16/2004
72/16/2004Ifunsorted&morefuncavailable
82/28/20044
92/28/2004
103/5/2004
113/5/2004
123/15/2004
133/17/2004
143/19/2004
153/19/2004
163/28/2004
174/4/2004
184/7/2004
194/11/2004
205/1/2004
Sheet1


Formulas...

C1:

=MATCH(9.99999999999999E+307,A:A)

If column A is set in ascending order (a prerequisite)...

D2:

=MIN(IF((A2:INDEX(A:A,C1)>=C3),ROW(A2:INDEX(A:A,C1))))

which must be confirmed with control+shift+enter instead of just enter.

D3:

=MATCH(C4,A:A)

E3, copied to E4...

=INDEX(A:A,D3)

in order to show from which date to which date the computation is really done.

C5:

=SUMPRODUCT(1/COUNTIF(OFFSET($A$1,D3-1,0,D4-D3+1,1),OFFSET($A$1,D3-1,0,D4-D3+1,1)))

which does effect a conditional unique date count.

If column A is unsorted and the morefunc.xll add-in is available...

C8:

=COUNT(UNIQUEVALUES(IF((A2:INDEX(A:A,C1)>=C3)*(A2:INDEX(A:A,C1)<=C4),A2:INDEX(A:A,C1))))

which must be confirmed with control+shift+enter instead of just with enter.
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,241
Messages
6,123,823
Members
449,127
Latest member
Cyko

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