Calculating days

Laguna11

New Member
Joined
Sep 25, 2010
Messages
26
Could anybody help shed some light on the following please?

I need to calculate the number of days between 2 dates, however if the end date is a weekend or a public holiday I need it to count up to the previous working day. If the start date and end date straddle a weekend then it must count the weekend. I have a separate worksheet with all the public holidays listed.

Many thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Did you use the second formula I suggested......with +1 at the end?

=WORKDAY(B1+1,-1,holidays)-A1+1

Using that version I got the same results as you suggested......
 
Upvote 0
It works!!!! :laugh: Thank you, Thank you, Thank you!!!! You wouldn't believe that I awoke in the middle of the night dreaming of formulas would you!?!

Thank you all ever so much for your help!
 
Upvote 0
Can I ask for some further help please?

I am now looking at a start date. If a start date is a weekend or a public holiday I need the next working date, but if the start date is a Monday to Friday (and is not a public holiday) then it counts that date as the start date.

I have been able to get the next working day after a weekend and public holiday but I can't get it to count a normal Monday to Friday as day 1.

=WORKDAY(E17,1,'Public Holidays'!A3:A14)
 
Upvote 0
You can use the same technique that I employed in the other formula, subtract 1 from the date and then add 1 workday - that will give you an unchanged date for workdays....or the next working day for non-workdays, i.e.

=WORKDAY(E17-1,1,'Public Holidays'!A3:A14)
 
Upvote 0
Once again- thank you! It's perfect! :-)

I had been playing around with your formula, but since I did not understand how the +1,-1 bit worked it was very hit and miss!!!
 
Upvote 0
If both the start and end date are on a weekend/public holiday with no working days in between could it return a 0 value?

eg. 28/05/2011 - 30/05/2011 (30/05/2011 being a public holiday)
 
Upvote 0
So currently you are using something like this

=WORKDAY(B1+1,-1,holidays)-WORKDAY(A1-1,1,holidays)+1

..and you get a negative result?

You can use MAX to make the lowest value zero, i.e.

=MAX(WORKDAY(B1+1,-1,holidays)-WORKDAY(A1-1,1,holidays)+1,0)
 
Upvote 0
You're my knight in shining armour! :) Thanks!

I'm not using the formula as you suggest above as I also need to look at the start and end dates as they could contain text after the date such as AM or PM, if only a half day of sick leave has been taken, and I need to reflect this.

I think I have error trapped all my formulas now and I have tested it with all possible scenarios. This is going to make a huge difference to me time wise at work- and with your (and the others) help I have learnt a bit more in Excel!
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

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