Count days from date range

Maride

New Member
Joined
Jul 13, 2021
Messages
7
Office Version
  1. 2013
Platform
  1. Windows
I have a list of time off requests that are listed as date ranges (ie. 6/7/21 - 6/10/21 ) and I need to make a count of how many days off are requested for each date, ideally without having to manually input each date between the date ranges. So i want to be able to input


6/7/21 - 6/10/21
6/8/21 - 6/8/21
6/8/21 - 6/9/21
and be able to get a list

6/7/21 - 1
6/8/21 - 3
6/9/21 - 2
6/10/21 1
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the Board!

The issue is that entries like "6/7/21 - 6/10/21" are text entries, and not date entries. So it is difficult to do mathematical computation on them without creating some conversion formulas instead.

If you have the ability to split up, so you have two columns, one for the Start Date and one for the End Date, this becomes a much easier task.

So let's say that the Start Dates are in A1:A3 and the corresponding end dates are in B1:B3.
And we have the date 6/7/21 in cell A6, and wanted to count how many people have that day off, then we could use this formula:
Excel Formula:
=COUNTIFS($A$1:$A$3,"<="&A6,$B$1:$B$3,">="&A6)

If you cannot change how you receive the data, and will always receive it like "6/7/21 - 6/10/21", then you can write formulas to split up.
So, for an entry in cell A1, the Start Date formula would look like this:
Excel Formula:
=DATEVALUE(TRIM(LEFT(SUBSTITUTE(A1,"-",REPT(" ",20)),20)))
and the End Date formula would look like this:
Excel Formula:
=DATEVALUE(TRIM(RIGHT(SUBSTITUTE(A1,"-",REPT(" ",20)),20)))
 
Upvote 0
Solution
So I do have them split the issue is howcan i get a count of how many people have 6/8 and 6/9 off if I have 6/7 as start and 6/10 as end without having to manually input a cell for 6/8 and 6/9
 
Upvote 0
So I do have them split the issue is howcan i get a count of how many people have 6/8 and 6/9 off if I have 6/7 as start and 6/10 as end without having to manually input a cell for 6/8 and 6/9
Look again at the first explanation and formula I provided.
That formula returns exactly what you are asking for.
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Count days off from date range
and Pivot Table from Date Range
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Look again at the first explanation and formula I provided.
That formula returns exactly what you are asking for.
Maybe Im misunderstanding..I've attached a sample of what I am trying to get
 

Attachments

  • excel.JPG
    excel.JPG
    38 KB · Views: 12
Upvote 0
Look again at the first explanation and formula I provided.
That formula returns exactly what you are asking for.
So I have the formula in there its returning a 0 with no errors, but its not returning a count when i list days in that date range

sample.xlsx
ABCDEFGHI
1EmployeeStart DateEnd DateEmployees Off
2Jon7-Jun7-Jun7-Jun0
3jack7-Jun10-Jun8-Jun0
4sally9-Jun10-Jun9-Jun0
5 june10-Jun10-Jun10-Jun0
6 jared10-Jun11-Jun11-Jun0
7sue11-Jun11-Jun
8
9
Sheet1
Cell Formulas
RangeFormula
G2G2=COUNTIFS($B$2:$B$7,"<="&F2,$C$2:$C$7,">=""F2")
G3G3=COUNTIFS($B$2:$B$7,"<="&F3,$C$2:$C$7,">=""F3")
G4G4=COUNTIFS($B$2:$B$7,"<="&F4,$C$2:$C$7,">=""F4")
G5G5=COUNTIFS($B$2:$B$7,"<="&F5,$C$2:$C$7,">=""F5")
G6G6=COUNTIFS($B$2:$B$7,"<="&F6,$C$2:$C$7,">=""F6")
 
Upvote 0
You have a typo in your formula. You have a bunch of quotes around the last range reference, which then makes it the literal text value "F2", not the cell D2.
Try changing the formula in G2 to:
=COUNTIFS($B$2:$B$7,"<="&F2,$C$2:$C$7,">=" & F2)
 
Upvote 0
You have a typo in your formula. You have a bunch of quotes around the last range reference, which then makes it the literal text value "F2", not the cell D2.
Try changing the formula in G2 to:
=COUNTIFS($B$2:$B$7,"<="&F2,$C$2:$C$7,">=" & F2)

OMG IT WORKED thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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