Counting Days between a set of days

arocha118

New Member
Joined
Jan 9, 2019
Messages
7
I'm trying to could the number of days between a set of days.
Example:
1/1/19 - 12/31/19.
I need to could the days between 6/1 & 11/31 and never mind the year. If the dates are 1/1/19 to 12/31/20 then I need it to count them.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
[TABLE="class: grid, width: 203"]
<tbody>[TR]
[TD]Begin[/TD]
[TD]End[/TD]
[TD]Difference[/TD]
[/TR]
[TR]
[TD="align: right"]1/1/2019[/TD]
[TD="align: right"]12/31/2019[/TD]
[TD="align: right"]364[/TD]
[/TR]
</tbody>[/TABLE]

Code:
=B2 - A2

To be inclusive (counting begin and end in the count):
Code:
=(B2 - A2) +1
 
Last edited:
Upvote 0
Thank you,

I'm looking for a subset. I only want to count the days between June and November. The original range could be 1/1/19 -10/15/19 or something like 6/15/19 - 6/5
/20
 
Upvote 0
I'm trying to could the number of days between a set of days.
Example:
1/1/19 - 12/31/19.
I need to could the days between 6/1 & 11/31 and never mind the year. If the dates are 1/1/19 to 12/31/20 then I need it to count them.

There is a straightforward formula that you can use for that:
=Days(End Date, Start Date)

To use your example, it will return 730 days if your values are 1/1/19 and 12/31/20.
 
Upvote 0
Hi,
I've accidently suggested you the wrong worksheet function. Use the one below to count network days.
It's got three paramters of which first two are required: first one is startdate ex 01.01.2019 and the second parameter are enddate ex. 31.01.2019. Both has to be formated as dates. Those two parameters calculate days from Mon to Fri between dwo dates ( it skips Saturdays and Sundays). The third parameter is optional, and here you can assign range or array of addidional holidays which are with Mon-Fri between start/end date. Here's an example of code I created. Start date I pool from range A2, end date from range B2 and optionally range of additional holidays range C2:C5. If you do not want to add addigional holidays to calculation just skip this third parameter and place only two.
Code:
Sub NetWorkDays()
    Dim StartDate As Date
    Dim EndDate As Date
    Dim rng_holidays As Range
    Dim WorkDays&
    Dim arr()
    
    Set rng_holidays = ActiveSheet.Range("C2:C5") 'setting the range of additional holidays which are within Mon-Fri
    StartDate = Range("A2")
    EndDate = Range("B2")
    
    arr = rng_holidays
    'As third parameter you ca use either range of additional holidays (dates) or array that include records of holidays
    'WorkDays=Application.WorksheetFunction.NetworkDays(StartDate, EndDate, rng_holidays)
    WorkDays = Application.WorksheetFunction.NetWorkDays(StartDate, EndDate, arr)
    ActiveSheet.Range("D2") = rng_holidays
    
    Set rng_holidays = Nothing
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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