Count of days between two dates, but within a given period

Excellerator365

New Member
Joined
Nov 14, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

For payroll purposes I need to be able to calculate the amount of days between two dates, but within a given payroll period.
I need this in a formula that I can drag accross all my data (alot of it)

Any help is greatly apprechiated.

1668463552634.png
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Welcome to the forum.

I think this does it. There are several nested IF statements, which is amateurish, but I couldn't reckon another way on such short notice.

[Please download the MrExcel Message Board App so you can upload data and save us having to type it in. See my signature below for the link.]

MrExcel posts19.xlsx
BCDEFGHIJKLMNOP
3begin:1/1/20222/1/20223/1/20224/1/20225/1/20226/1/20227/1/20228/1/20229/1/202210/1/202211/1/202212/1/2022
4end:1/31/20222/28/20223/31/20224/30/20225/31/20226/30/20227/31/20228/31/20229/30/202210/31/202211/30/202212/31/2022
5
6startfinish
712/15/20216/15/2022312831303115000000
85/5/20222/15/202300002730313130313031
91/10/202210/20/20222228313031303131302000
Sheet32
Cell Formulas
RangeFormula
E7:P9E7=IF(($B7<E$3)*($C7>E$4),E$4-E$3+1,IF(($C7<E$4)*($C7>=E$3),$C7-E$3+1,IF(($B7>=E$3)*($B7<=E$4),E$4-$B7+1,0)))
 
Upvote 0
Is it days (as mentioned in the question and thread title) or days worked (as mentioned in the screen capture)?
This is based on a 7 day working week with no holidays. You can amend the weekend and holiday parameters of the NETWORKDAYS.INTL function as required.
Mr Excel 14-11-22.xlsx
ABCDEFGHIJKLMNO
1Start01/01/202201/02/202201/03/202201/04/202201/05/202201/06/202201/07/202201/08/202201/09/202201/10/202201/11/202201/12/2022
2End31/01/202228/02/202231/03/202230/04/202231/05/202230/06/202231/07/202231/08/202230/09/202231/10/202230/11/202231/12/2022
3
4Days
5StartEnd
615/12/202115/03/2022312815000000000
705/05/202215/02/202300002730313130313031
810/01/202220/10/20222228313031303131302000
Sheet10
Cell Formulas
RangeFormula
D6:O8D6=MAX(0,NETWORKDAYS.INTL(MAX($A6,D$1),MIN($B6,D$2),"0000000"))
 
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: Calculate Working Days Between Two Dates
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

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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