Countif to return # of cells with dates containing X year

mbeardsl

New Member
Joined
Nov 28, 2016
Messages
12
I'm struggling with getting a formula to work.

I have dates in column H. I simply want to count how many times a date occurs with 2016 (or a referenced cell) in the year.

This is as close as I've gotten, but isn't what I'm wanting as the dates will eventually go past 2016 and then the count will be including 2017 dates.

=COUNTIF(H2:H15,">"&DATE(2016,1,1))

Thanks in advance!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try:

=COUNTIFS(H2:H15,">="&DATE(2016,1,1),H2:H15,"<="&DATE(2016,12,31))

and you can put 2016 in a cell if you want.
 
Upvote 0
Thanks guys. Those work perfectly.

Instead of the first one, I could just use this instead for slight simplicity?

=COUNTIFS(H:H,">="&DATE(I1,1,1),H:H,"<"&DATE(I1+1,1,1)) ***vs "<="&DATE(I1+1,1,1)-1) ***
 
Upvote 0
I1: 2016

J1:

=COUNTIFS(H:H,">="&DATE(I1,1,1),H:H,"<="&DATE(I1+1,1,1)-1)<strike></strike>
There is a potential pitfall in this formula: if column H has dates with times, anything beyond 31-JAN-2016 00:00:00 will not be counted.

Here is a shorter and a more robust formula:

=COUNTIFS(H:H,">="&I1&"-1-1",H:H,"<"&I1+1&"-1-1")
 
Upvote 0
Here it is:

Let's assume cell I1 has a value of 2016. Then I1&"-1-1" yields "2016-1-1", and I1+1&"-1-1" yields "2017-1-1".

The formula thus becomes =COUNTIFS(H:H,">=2016-1-1",H:H,"<2017-1-1"), and Excel does the job.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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