Jump to content

Return array of next x working days


John_A

Recommended Posts

Hi,

 

I need a function to return the next x working days (Mon - Fri). So for 7 from today it would return: -

 

Monday 8th March

Tuesday 9th March

Wednesday 10th March

Thursday 11th March

Friday 12th March

Monday 15th March

Tuesday 16th March

 

But also with the ability to pass to it days to be excluded (for example Christmas / Boxing day and New Year's Day, as well as any custom public holidays).

 

I've done something similar before but it ended up being rather long, I'm looking to keep this as short and simple as possible....any ideas?

Link to comment
Share on other sites

You could probably make a loop and check for Saturday / Sunday, if it is equal to that then omit.

 

For the holidays, well you would have to take into account the "Observed" Holiday and calculate that, so you could not just simply define a date and viola! But it would be the same type of deal, if the date is equal to this date (either hardcoded in there or into an array) then you omit it and continue onwards.

 

I am sure there are plenty of Calendar scripts that have this functionality that you could look at the decipher to create your own special function.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.