cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

DateAdd excluding weekends

Hi,

 

I have DatePicker2 wherein the default value comes from DatePicker1 + 15days. Can someone help me out exclude saturday and sunday when adding the 15 days to the selected date on DatePicker1?

 

Scenario:

 

DatePicker1 = 07/02/2018

DatePicker2 = 07/02/2018 + 15 days (excluding saturday & sunday)

 

Please help,

 

Thanks in advance

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeteMc Resolver I
Resolver I

Re: DateAdd excluding weekends

Find sample app attached. What I did:

Set the onChange on datepicker1 to:

 

Set(DateCalcTable,AddColumns(Table({ID:1},{ID:2},{ID:3},{ID:4},{ID:5},{ID:6},{ID:7},{ID:8},{ID:9},{ID:10},{ID:11},{ID:12},{ID:13},{ID:14},{ID:15},{ID:16},{ID:17},{ID:18},{ID:19},{ID:20}),"WeekDayCol",Weekday(DateAdd(DatePicker1.SelectedDate,ID,Days))));
Set(NewDate,DateAdd(DatePicker1.SelectedDate,Last(FirstN(Filter(DateCalcTable,WeekDayCol > 1 && WeekDayCol < 7),15)).ID,Days));
Set(resetDatePicker2, true);
Set(resetDatePicker2, false)

Set the reset on DatePicker2 to: 

resetDatePicker2

Set the default on DatePicker2 to  

NewDate

 

View solution in original post

2 REPLIES 2
PeteMc Resolver I
Resolver I

Re: DateAdd excluding weekends

Find sample app attached. What I did:

Set the onChange on datepicker1 to:

 

Set(DateCalcTable,AddColumns(Table({ID:1},{ID:2},{ID:3},{ID:4},{ID:5},{ID:6},{ID:7},{ID:8},{ID:9},{ID:10},{ID:11},{ID:12},{ID:13},{ID:14},{ID:15},{ID:16},{ID:17},{ID:18},{ID:19},{ID:20}),"WeekDayCol",Weekday(DateAdd(DatePicker1.SelectedDate,ID,Days))));
Set(NewDate,DateAdd(DatePicker1.SelectedDate,Last(FirstN(Filter(DateCalcTable,WeekDayCol > 1 && WeekDayCol < 7),15)).ID,Days));
Set(resetDatePicker2, true);
Set(resetDatePicker2, false)

Set the reset on DatePicker2 to: 

resetDatePicker2

Set the default on DatePicker2 to  

NewDate

 

View solution in original post

Anonymous
Not applicable

Re: DateAdd excluding weekends

Thank you so much

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,111)