[Solved] Count cells for a date range
[Solved] Count cells for a date range
I have a column of dates. Need to count the number of those date entries based on month and year only. Basically trying to see how many "widgets" sold per month per year. Thank you.
Last edited by Hagar Delest on Sun Sep 24, 2017 9:15 pm, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice 4.1.3, Windows 10
Re: Count cells for a date range
Greetings and welcome to the community forum!
If A1:A4 is the range containing the dates, and you wanted the number of dates in January of this year, something like this will work:
=SUMPRODUCT(A1:A4>=DATE(2017;1;1);A1:A4<=DATE(2017;1;31))
If you wanted to count dates that are in September of any year, maybe something like this:
=SUMPRODUCT(MONTH(A1:A4)=1)
The SUMPRODUCT here is just adding up zeroes and ones (the results of the boolean comparisons) to give a count; I used it instead of plain SUM out of convenience, since these are array formulas and SUMPRODUCT provides its own array context.
If A1:A4 is the range containing the dates, and you wanted the number of dates in January of this year, something like this will work:
=SUMPRODUCT(A1:A4>=DATE(2017;1;1);A1:A4<=DATE(2017;1;31))
If you wanted to count dates that are in September of any year, maybe something like this:
=SUMPRODUCT(MONTH(A1:A4)=1)
The SUMPRODUCT here is just adding up zeroes and ones (the results of the boolean comparisons) to give a count; I used it instead of plain SUM out of convenience, since these are array formulas and SUMPRODUCT provides its own array context.
AOO4/LO5 • Linux • Fedora 23
Re: Count cells for a date range
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Count cells for a date range
I think acknak had January on his mind( =1 ); instead of the 1 , use 9 for September.If you wanted to count dates that are in September of any year, maybe something like this:
=SUMPRODUCT(MONTH(A1:A4)=1)
3.4.1 & 4.1.5 on MS Windows 7 Pro x64
Re: Count cells for a date range
Thank you for the replies. I kept working on it since my original post and came up with the sumproduct solution. Thanks again!
OpenOffice 4.1.3, Windows 10