[Solved] Count number of dates in current month

Discuss the spreadsheet application
Post Reply
maggieyoung76
Posts: 8
Joined: Mon Dec 05, 2016 4:34 pm

[Solved] Count number of dates in current month

Post by maggieyoung76 »

Hi all,

I am struggling to find way to Count number of dates in current month. My column has conditional formatting showing all dates that fall in current month. Can you help me count them?

Thank you :)

Maggie
Last edited by Hagar Delest on Mon Dec 05, 2016 10:34 pm, edited 1 time in total.
Reason: tagged [Solved].
openoffice 5.2 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Count number of dates in current month

Post by Villeroy »

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
maggieyoung76
Posts: 8
Joined: Mon Dec 05, 2016 4:34 pm

Re: Count number of dates in current month

Post by maggieyoung76 »

Hi, thanks for that.

I don't need number of days in current month or a particular month. I have a column called Date Acquired and need to see the dates in the column that are in the current month. Hope that makes :)

Maggie
openoffice 5.2 on Windows 10
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Count number of dates in current month

Post by acknak »

If the dates are in A1:A10, something like this should work:

=SUMPRODUCT(MONTH(A1:A10)=MONTH(TODAY()))

Note: if you have empty cells, or non-date cells in that range, the formula will need to be changed or it may give the wrong answer.
AOO4/LO5 • Linux • Fedora 23
maggieyoung76
Posts: 8
Joined: Mon Dec 05, 2016 4:34 pm

Re: Count number of dates in current month

Post by maggieyoung76 »

Hi there, do you have it so it will work with dates? Thank you so much.

Maggie
openoffice 5.2 on Windows 10
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Count number of dates in current month

Post by acknak »

Yes, that works with dates. MONTH takes a date and returns the month number: MONTH("2016-12-05") returns 12.

If the formula isn't working, your dates may actually be text, in which case it may produce an error.
AOO4/LO5 • Linux • Fedora 23
maggieyoung76
Posts: 8
Joined: Mon Dec 05, 2016 4:34 pm

Re: Count number of dates in current month

Post by maggieyoung76 »

Hi, my column is set to dates but the formula is returning random numbers for the column range. I've attached the sheet and highlighted where I need the calculation to be. can you please take a peek?
Attachments
Untitled 1.ods
(17.81 KiB) Downloaded 101 times
openoffice 5.2 on Windows 10
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Count number of dates in current month

Post by acknak »

The formula won't work with empty cells: it takes an empty cell as zero, which represents a date in December.

The attached sheet has a modified formula that ignores empty cells:
=SUMPRODUCT(M10:M20<>"";MONTH(M10:M20)=MONTH(TODAY()))

Setting a cell format to "Date" does not change the type of data stored in the cell. You can check the data type using View > Value Highlighting: ON: text data will appear in black; numbers or dates in blue.
Attachments
count_dates_sample.ods
(15.27 KiB) Downloaded 132 times
AOO4/LO5 • Linux • Fedora 23
maggieyoung76
Posts: 8
Joined: Mon Dec 05, 2016 4:34 pm

Re: Count number of dates in current month

Post by maggieyoung76 »

That's really helpful, thank you very much indeed.

maggie
openoffice 5.2 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Count number of dates in current month

Post by Villeroy »

1000 random dates grouped by year and month and counted by a pivot table (aka data pilot).
https://wiki.openoffice.org/wiki/Docume ... /DataPilot
Attachments
date_pivot.ods
Nother year/month pivot
(27.57 KiB) Downloaded 150 times
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
maggieyoung76
Posts: 8
Joined: Mon Dec 05, 2016 4:34 pm

Re: [Solved] Count number of dates in current month

Post by maggieyoung76 »

Thank you Villeroy!

Maggie
openoffice 5.2 on Windows 10
Post Reply