Reputation: 641
I would like to know how many times a a specific year is found in a column. Format of column C is Date (for example: 15/2/2021). Obviously the code below doesn't work, but to give you an idea:
In the example above the output on B:1 should be: 3
Upvotes: 2
Views: 1442
Reputation: 1
use:
=INDEX(COUNTIF(YEAR(C:C); A1))
or get whole table with:
=QUERY(C:C;
"select year(C),count(C)
where C is not null
group by year(C)
label year(C)'',count(C)''")
Upvotes: 5
Reputation: 4219
You can use this workaround:
cell B1
formula:
=COUNTIFS(C:C,">="&A1&"-01-01",C:C,"<"&(A1+1)&"-01-01")
And then apply the same formula for the rest of column B
cells.
It will count everything which is greater than or equal to the first day of the year and lower than the first day of next year. It is not pretty but it works.
Upvotes: 4