Solved

# Number of specific dates or days between two dates

Posted on 2011-09-19
220 Views
Hi,

I need a formula that can work out how many dates or days are between two dates, i.e. how many FRI between 1/1/2011 and 10/6/2011 or how many 21st's are there between the dates etc
0
Question by:StormFusion
• 2
• 2
• 2
• +1

LVL 3

Accepted Solution

lisa_mc earned 75 total points
ID: 36559418
hi

to find how many days eg monday or so on use

Number Of Mondays In Period

If you need to return the number of Monday's (or any other day) that occur within an interval between two dates, use the following Array Formula:

=SUM(IF(WEEKDAY(A2-1+ROW(INDIRECT("1:"&TRUNC(B2-A2)+1)))=C2,1,0))

This formula assumes the following:
A2 contains the beginning date of the interval
B2 contains the ending date of the interval
C2 contains the day-of-week number (1=Sunday, 2=Monday,...,7=Saturday)

examples from
http://www.cpearson.com/excel/datetimews.htm
0

LVL 3

Expert Comment

ID: 36559424

http://www.cpearson.com/excel/DateIntervals.htm
0

LVL 50

Expert Comment

ID: 36559442
Hello,

to work out the number of days between to dates you simply need to subtract the earlier date from the later date

Say A1 is 1/01/2011 and A2 is 1/04/2011 (April-1-2011)

=A2-A1

will return 90 (days).

As a rough guideline, you could divide that result by 7 too arrive at the number of Fridays or any other weekday as an average.

Your also ask about how many 21sts there are. This seems like quite a few requirements. What exactly do you want to return?

Can you post a workbook with some data and manually mocked up results?

cheers, teylyn
0

Author Comment

ID: 36559498
The first reply above works perfect for working out certain days between two dates, thats fine.

But I also need to work out for example... 1/1/2011 to 27//4/2011 and looking for 28th's, would give me a result of 3, because it would see 28/1/2011, 28/2/2011 and 28/3/2011 but not 28/4/2011 as the to date finishes on the 27th.
0

LVL 92

Assisted Solution

Patrick Matthews earned 50 total points
ID: 36559741
Same basic approach should work to count the number of indicated days of the month:

Assuming that your day of the month is in D2...

{=SUM(IF(DAY(A2-1+ROW(INDIRECT("1:"&TRUNC(B2-A2)+1)))=D2,1,0))}

As before, that is an array formula.  To enter an array formula, do not enter the curly braces, and hit Ctrl+Shift+Enter instead of Enter to finish it off.  Excel will then display those braces to indicate that it's an array formula.
0

Author Comment

ID: 36562607
Lisa_mc thankyou for those, and mathewpartrick thanks, tried to change it to also count number of certain months between date by changing DAY to MONTH but didnt work?
0

LVL 92

Expert Comment

ID: 36567674
StormFusion,

With respect, I think your original question has been answered.  If you want to tackle that months part, I suggest you create a new question for it.

Patrick
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Excel Question 17 15
VBA Works in Excel 2010 Not 2016 Help! 5 22
Excel - click on a cell and have everything in another cell clear 13 33
Excel - remove duplicates 1 14
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…