Hi folks,
I noticed that the DateDiff calculation between two dates excluding weekends and holidays are well documented. I'm having an app that allow the users to pick a start date and end date for a task, and the task could be repetitive. So I'd like to find out the number of recurrences between the 2 dates excluding weekends, and most importantly to find out which exact dates they are.
Here my code:
ClearCollect(collRecurrence,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60]); ClearCollect(_tempText,[]); //DataCardValue9 is Start Date; //DataCardValue10 is End Date; //_NoOfSelected is the number of days where the task is repeating. Eg every 2 days, _NoOfSelected is 2; Set(_Frequency, RoundDown((RoundDown(DateDiff(DataCardValue9.SelectedDate, DateValue(DataCardValue10.SelectedDate), Days) / 7, 0) * 5 + Mod(5 + Weekday(DateValue(_RepeatUntilSelected)) - Weekday(DataCardValue9.SelectedDate),5)) / _NoOfSelected, 0)); If(Toggle1.Value=true, ForAll( Filter( collRecurrence, Value < _Frequency ), Collect(_tempText, If(Weekday(DateAdd(DataCardValue9.SelectedDate, Value * _NoOfSelected)) = 1 Or Weekday(DateAdd(DataCardValue9.SelectedDate, Value * _NoOfSelected)) = 7, DateAdd(DataCardValue9.SelectedDate + 2, Value * _NoOfSelected), DateAdd(DataCardValue9.SelectedDate, Value * _NoOfSelected))); Reset(Toggle1); ), Reset(Toggle1); );
Obviously ... this code is not correct ... but I have no clue how to find out the exact dates.
Please give me some advice 🙂
Thanks,
Gavin
Hi @gavinleung ,
Did you mean that you want to find how many tasks start and end on the same day during one period of time? And also extract the dates between the start and end dates?
Regards,
Mona
Hi @v-monli-msft , not exactly.
Say eg Task A will start on 20/9, and repeating every 2 days until 30/9. Weekends shouldn't be taken. That means Task A shall happen on 20/9, 24/9, 26/9 and 30/9. So the code I provided is to calculate the number of recurrence of this task, ie 4 times. But now, I don't know the code that I could extract these 4 dates and adding to a Sharepoint List.
Check out new user group experience and if you are a leader please create your group
Did you miss the call?? Check out the Power Apps Community Call here!
User | Count |
---|---|
254 | |
207 | |
76 | |
37 | |
33 |
User | Count |
---|---|
326 | |
216 | |
124 | |
71 | |
54 |