Solved

Number of specific dates or days between two dates

Posted on 2011-09-19
7
223 Views
Last Modified: 2012-05-12
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
Comment
Question by:StormFusion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 3

Accepted Solution

by:
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

by:lisa_mc
ID: 36559424
and the link below will help you out with the second problem

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

Expert Comment

by:Ingeborg Hawighorst
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:StormFusion
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

by:Patrick Matthews
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

by:StormFusion
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

by:Patrick Matthews
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question