Between 2 dates, Count number of times specific day occurs

abaxter

New Member
Joined
Aug 20, 2016
Messages
9
Would like to have a formula that counts the number times a specific day of the month occurs between two dates. For example:

Starting Date: TODAY
End Date: April 5th

How many 20th of the months occur between the two dates? A simple formula to count months isn't going to account for where you are in the current month. For example, the formula should calculate 3 based on today's date (Jan 14th) but it should only calculate 2 if today were Jan 21st.

Thanks!
Andrew
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
For the dates in b1:b2 try this: =1+MONTH(B2)-MONTH(B1)-(DAY(B2)<20)-(DAY(B1)>20)
 
Last edited:
Upvote 0
What is the formula that ignores the year? For example, the number of the 27th day between 5 October 2020 and 27 January 2021.
 
Upvote 0
Hi,

What result do you expect 4 or 8?

Try this formula that actually takes years into account and returns 4:
=1+MONTH(B2)+YEAR(B2)*12-MONTH(B1)-YEAR(B1)*12-(DAY(B2)<27)-(DAY(B1)>27)

for result = 8 use that one:
=ABS(1+MONTH(B2)-MONTH(B1)-(DAY(B2)<27)-(DAY(B1)>27))
 
Last edited:
Upvote 0
Hi,

What result do you expect 4 or 8?

Try this formula that actually takes years into account and returns 4:
=1+MONTH(B2)+YEAR(B2)*12-MONTH(B1)-YEAR(B1)*12-(DAY(B2)<27)-(DAY(B1)>27)

for result = 8 use that one:
=ABS(1+MONTH(B2)-MONTH(B1)-(DAY(B2)<27)-(DAY(B1)>27))

I expect 4 as a result. I have copied the formula and it works.

Thank you for your help.
 
Upvote 0
Glad it is working as expected!
Welcome to MrExcel Board! :)
 
Upvote 0

Forum statistics

Threads
1,215,336
Messages
6,124,331
Members
449,155
Latest member
ravioli44

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