Solved

Number of specific dates or days between two dates

Posted on 2011-09-19
7
221 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

791 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