Counting the number of calendar days in a range with conditions

djmsenior

New Member
Joined
Jun 2, 2009
Messages
28
Office Version
  1. 365
Platform
  1. Windows
I'm trying to find the number of calendar days in a range with conditions.

The list is has 2 columns

Column A has the names
Column B has the date & time - the data isn't being exported correctly so I'm having to use DATEVALUE to convert it

I thought I could use:
=countifs(DATEVALUE(B2:B15),">="&C3,DATEVALUE(B2:B15),"<="&D3,A2:A15,D2)

But this isn't working, so any help gratefully received.

ABCD
AgentStartJuneErnest Rookwood
Elton John2023-06-01 08:51:39
01/06/2023​
30/06/2023​
Elton John2023-06-02 07:56:56
Elton John2023-06-05 08:47:58
Elton John2023-06-07 13:46:24
Freddie Mercury2023-06-01 08:51:39=countifs(DATEVALUE(B2:B15),">="&C3,DATEVALUE(B2:B15),"<="&D3,A2:A15,D2)
Freddie Mercury2023-06-02 07:56:56
Freddie Mercury2023-06-05 08:47:58
Freddie Mercury2023-06-07 13:46:24
Freddie Mercury2023-06-08 13:34:37
Freddie Mercury2023-06-09 13:46:21
Freddie Mercury2023-06-12 07:59:57
Freddie Mercury2023-06-13 13:05:49
Freddie Mercury2023-06-14 11:01:36
Freddie Mercury2023-06-15 10:53:17
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
See if the following formulas work for you:
Excel Formula:
=SUMPRODUCT(--(DATEVALUE(B2:B15)>=C3),--(DATEVALUE(B2:B15)<D3+1),--(A2:A15=D2))
=SUMPRODUCT(--(--B2:B15>=C3),--(--B2:B15<D3+1),--(A2:A15=D2))
 
Upvote 0
See if the following formulas work for you:
Excel Formula:
=SUMPRODUCT(--(DATEVALUE(B2:B15)>=C3),--(DATEVALUE(B2:B15)<D3+1),--(A2:A15=D2))
=SUMPRODUCT(--(--B2:B15>=C3),--(--B2:B15<D3+1),--(A2:A15=D2))
Hey Tetra201 - many thanks for responding so quickly!

Your formula works but it's highlighted the fact that I haven't asked the right question!!

With the following dataset:
Elton John2023-06-01 08:51:39
Elton John2023-06-01 16:14:11
Elton John2023-06-01 16:46:34
Elton John2023-06-02 08:15:53
Freddie Mercury2023-06-09 13:46:16
Freddie Mercury2023-06-09 13:46:17
Freddie Mercury2023-06-09 13:46:18
Freddie Mercury2023-06-09 13:46:19
Freddie Mercury2023-06-09 13:46:20
Freddie Mercury2023-06-09 13:46:21
Freddie Mercury2023-06-12 07:59:57
Freddie Mercury2023-06-13 13:05:49
Freddie Mercury2023-06-14 11:01:36
Freddie Mercury2023-06-15 10:53:17

I want to workout that:
Elton John has worked on 2 separate days
Freddie Mercury has worked on 5 separate days
 
Upvote 0
The following formula returns your expected results:
Excel Formula:
=COUNT(UNIQUE(FILTER(INT(B2:B15),(--B2:B15>=C3)*(--B2:B15<D3+1)*(A2:A15=D2))))
 
Upvote 0
The following formula returns your expected results:
Excel Formula:
=COUNT(UNIQUE(FILTER(INT(B2:B15),(--B2:B15>=C3)*(--B2:B15<D3+1)*(A2:A15=D2))))
Thank you so much. 🙏 I think it may be time for dinner.
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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