10 Replies Latest reply on Mar 26, 2015 9:11 PM by Alexander Mou

# Is there a way to add just workdays to a date

I want to add just work days to a particular date (set by a parameter). So adding 10 days to February 1st 2015 would get me  February 13th 2015.

• ###### 1. Re: Is there a way to add just workdays to a date

Parameter has to be a Date type.

On Thu, Mar 12, 2015 at 2:41 PM, Alex Welch <

• ###### 2. Re: Is there a way to add just workdays to a date

Using 2015-02-1 as an example you would get 2015-02-11 which is only 8 work days (10 calendar days). The end result I am looking for is 2015-02-13 which is 5 'work days' (Monday, Tuesday, Wednesday, Thursday, and Friday inclusive)

• ###### 3. Re: Is there a way to add just workdays to a date

On Thu, Mar 12, 2015 at 2:59 PM, Alex Welch <

• ###### 4. Re: Is there a way to add just workdays to a date

Thank you for your help but that doesn't solve the underlying problem. It needs to be scalable. The above date situation was just an example. Imagine that the user could expand the scope from 10 to 20. Or that instead of starting on a Sunday (as 2015-02-01 is) that it started on 2015-02-04. In that case it spans over 2 weekends.

In each of those events simply adding 'days' will produce incorrect results.

• ###### 5. Re: Is there a way to add just workdays to a date

Starting on weekend +12, else +14.

if Date('weekday',[Parameter])=1 or Date('weekday',[Parameter])=7 then 12

else 14 end,

[Parameter]

)

1: Sunday

7: Saturday

On Thu, Mar 12, 2015 at 3:11 PM, Alex Welch <

• ###### 6. Re: Is there a way to add just workdays to a date

Again, what if it spans multiple weekends. Hard coding the number of days doesn't seem to be the way to go. I need it to be scale able over months.

• ###### 7. Re: Is there a way to add just workdays to a date

Just divide the datediff() by 7. One can make the numbers dynamic according

to the number of weeks in between.

On Fri, Mar 13, 2015 at 6:32 AM, Alex Welch <

• ###### 8. Re: Is there a way to add just workdays to a date

Would you be able to provide a workbook with a working example of this? I seem to be failing grasping what you are saying.

• ###### 9. Re: Is there a way to add just workdays to a date

Here comes the workbook | Tableau Public

Given the [Scope] of work days, calculate the [Date Difference]. Then add the difference to Start Date. You get the [End Date].

The formula is as follows:

[Scope%5]+ int([Scope]/5)*7+

if     DATEPART('weekday',[Start Date])=3 then iif([Scope%5] =4,2,0)

elseif DATEPART('weekday',[Start Date])=4 then iif([Scope%5]>=3,2,0)

elseif DATEPART('weekday',[Start Date])=5 then iif([Scope%5]>=2,2,0)

elseif DATEPART('weekday',[Start Date])=6 then iif([Scope%5]>=1,2,0)

elseif DATEPART('weekday',[Start Date])=7 then 1

else 0

end