5 Replies Latest reply on May 25, 2016 3:28 AM by erolst

# Calculate date excluding weekend

We consider saturdy, and sunday is holiday..

so when I add +10 with current date, It should show me the date excluding Saturday, sunday,

for example  If I input as (5/25/2016)+ 10 then result should be 6/8/2016

Is it make sense ?

• ###### 1. Re: Calculate date excluding weekend

Will something like this help:

• ###### 2. Re: Calculate date excluding weekend

Simple method:

Let ( [

targetDate = Get ( CurrentDate ) + x ;

dow = DayOfWeek ( targetDate ) ;

shift = Case ( dow = 7 ; 2 ; dow = 1 ; 1 )

] ;

targetDate + shift

)

dgurusamy wrote:

If I input as (5/25/2016)+ 10 then result should be 6/8/2016

No, it's 6/6/2016

• ###### 3. Re: Calculate date excluding weekend

A couple of alternatives that calculate it as 8th June 2016

Let ( [

startDate = getasdate( "25/5/2016" ) ;

days = 10 ;

day = If ( DayOfWeek ( startDate ) = 1 ; 7 ; DayOfWeek ( startDate ) - 1 )

];

startDate + days + If ( day = 6 ; 2 ; 0 ) +

( Floor ( ( days -1 + ( If ( day = 6 ; 1 ; Mod ( day ; 6 )^1 ) ) ) /5 ) *2 )

)

Or

Let ([ StartDate = GetAsDate("25/05/2016") ;

WorkDays = 10 ]

;

StartDate + Int ( WorkDays / 5 ) * 7 + Middle ( "12345012340123601256014560345623456" ; ( DayOfWeek ( StartDate ) - 1 ) * 5 + Mod ( WorkDays ; 5 ) + 1 ; 1 )

)

1 of 1 people found this helpful
• ###### 4. Re: Calculate date excluding weekend

erolst wrote:

No, it's 6/6/2016

It seems you're only shifting once for a weekend, but if there are multiple weekends in the dates between the number of workdays that need to be added on, it will calculate incorrectly.

• ###### 5. Re: Calculate date excluding weekend

So this is to be understood as someDate + x workdays?

Well, I see you already have some alternatives.