0

I am not a coder, not even close. But I need to use some javascript for a project of mine that has users who only work certain days of the week, and I need to calculate the end date for a task for each user based on the start date, duration, and then only counting that certain users working days.

The closest I have found so far is this: add/subtract business days in Javascript It uses weekend days 0 and 6 as variables but my users may have a non-working day of Monday, or some with Tuesday, Wednesday and Saturday. How do I alter the code, or use something that can take differing numbers of inputs (some one day, others 4 days) to calculate the correct end date, counting only the working days for that user?

So some context:

I have Bob who works on Monday and Tuesday, therefore his non-working days are the delta - Weds, Thu, Fri, Sat & Sun. I have Mike who works Mon - Fri so his non-working days are Sat & Sun. I have Karen who only works Sat & Sun so her non-working days are Mon- Fri. I use Bubble.is as the application interface and the users have a data field for working days and non-working days so I can use either. I have called the Javascript that exists (on the link) and it works fine by changing the start date and duration in the code to my bubble start date and duration. I have added the user NWD field (non-working days) which can be any number of fields from one NWD to 6 NWD. Using the Javascript code, I extended out the non-working days to reference NWD#1 to NWD#6 and the code falls over for anyone who does not have 6 NWD entries. Therefore the Javascript code needs to cater for someone who as NWD of 1 (Monday) and someone else who has NWD of 1,2,3,4,5 (Mon - Fri) and that is where it fell over.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • Can you please provide sample data, expected outcome, what you've tried so far and how it fails to meet expectations? – cybernetic.nomad Jan 08 '19 at 21:49
  • Updated some more detail to hopefully give more data, expected outcome and what has been tried so far and why it does not work – Paul Tidman Jan 08 '19 at 22:16
  • A picture is worth a thousand words, this includes screen caps of your workbook :). You can upload one to imgur.com and link to it, someone with enough reputation will likely insert it in your question for you. – cybernetic.nomad Jan 08 '19 at 23:01

0 Answers0