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

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

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

Thank you so much

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (41,604)