Hello Guys,
I want to add a number of days to a date and place the result in another date field.
Default property of EndDateValue
StartDateValue + NoAnnual and exclude weekends
StartDateValue is a date field
EndDateValue is a date field
NoAnnual is a datacard format Number field
Please help!
Solved! Go to Solution.
Hi @abieba ,
Could you please share a bit more about your scenario?
Do you want to add days to the start date with exclude weekends, then put the result into another date time filed?
I have made a test on my side, I think the Timer control could achieve your needs, please take a try with the following workaround:
Add a Timer control within your app, set the Duration property to following:
1000
set the Repeat property and AutoStart property to following:
true
set the OnTimerEnd property of the Timer control to following:
Clear(BaseDateRange); ForAll( FirstN([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], Value(TextInput1.Text)), Collect(BaseDateRange, {RowIndex: CountRows(BaseDateRange) + 1, Date: DateAdd(StartDate.SelectedDate, Value)}) ); UpdateIf(BaseDateRange, Weekday(Date)=1||Weekday(Date)=7, {Date: Blank()}); Set(BlankDate, CountIf(BaseDateRange, IsBlank(Date))); ForAll( RenameColumns(BaseDateRange, "RowIndex", "RowIndex1"), Patch( BaseDateRange, LookUp(BaseDateRange, RowIndex = RowIndex1), { Date: DateAdd(StartDate.SelectedDate, RowIndex1 + BlankDate) } ) )
on your side, you may type:
Clear(BaseDateRange); ForAll( FirstN([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], Value(NoAnnualDataCardValue.Text)), /* <-- NoAnnualDataCardValue represents the Text Input box , where you enter the Days to add to the Start date */ Collect(BaseDateRange, {RowIndex: CountRows(BaseDateRange) + 1, Date: DateAdd(StartDate.SelectedDate, Value)}) ); UpdateIf(BaseDateRange, Weekday(Date)=1||Weekday(Date)=7, {Date: Blank()}); Set(BlankDate, CountIf(BaseDateRange, IsBlank(Date))); ForAll( RenameColumns(BaseDateRange, "RowIndex", "RowIndex1"), Patch( BaseDateRange, LookUp(BaseDateRange, RowIndex = RowIndex1), { Date: DateAdd(StartDate.SelectedDate, RowIndex1 + BlankDate) } ) )
Set the Visible property of the Timer to following:
false /* <-- Hide the Timer control in your app */
Set the DefaultDate property of the End Date Picker to following:
Last(BaseDateRange).Date
Please consider take a try with above solution, then check if the issue is solved.
Best regards,
You will want to consider using the DATEADD function for this.
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff
Example Usage
DateAdd(Now(), 3, Days)
DateAdd(DataCardValue.SelectedDate, 3, Days)
Perhaps you could put the result of this function in another DatePicker input and use the previous formula I supplied to make the calculation. https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/exclude-weekeneds-in-date-calculatio...
---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."
Hello @mdevaney
i want to exclude weekends in the addition
so lets say i am adding 3 days to a thursday the result should show tuesday the following week instead of sunday.
Hi @abieba ,
Could you please share a bit more about your scenario?
Do you want to add days to the start date with exclude weekends, then put the result into another date time filed?
I have made a test on my side, I think the Timer control could achieve your needs, please take a try with the following workaround:
Add a Timer control within your app, set the Duration property to following:
1000
set the Repeat property and AutoStart property to following:
true
set the OnTimerEnd property of the Timer control to following:
Clear(BaseDateRange); ForAll( FirstN([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], Value(TextInput1.Text)), Collect(BaseDateRange, {RowIndex: CountRows(BaseDateRange) + 1, Date: DateAdd(StartDate.SelectedDate, Value)}) ); UpdateIf(BaseDateRange, Weekday(Date)=1||Weekday(Date)=7, {Date: Blank()}); Set(BlankDate, CountIf(BaseDateRange, IsBlank(Date))); ForAll( RenameColumns(BaseDateRange, "RowIndex", "RowIndex1"), Patch( BaseDateRange, LookUp(BaseDateRange, RowIndex = RowIndex1), { Date: DateAdd(StartDate.SelectedDate, RowIndex1 + BlankDate) } ) )
on your side, you may type:
Clear(BaseDateRange); ForAll( FirstN([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], Value(NoAnnualDataCardValue.Text)), /* <-- NoAnnualDataCardValue represents the Text Input box , where you enter the Days to add to the Start date */ Collect(BaseDateRange, {RowIndex: CountRows(BaseDateRange) + 1, Date: DateAdd(StartDate.SelectedDate, Value)}) ); UpdateIf(BaseDateRange, Weekday(Date)=1||Weekday(Date)=7, {Date: Blank()}); Set(BlankDate, CountIf(BaseDateRange, IsBlank(Date))); ForAll( RenameColumns(BaseDateRange, "RowIndex", "RowIndex1"), Patch( BaseDateRange, LookUp(BaseDateRange, RowIndex = RowIndex1), { Date: DateAdd(StartDate.SelectedDate, RowIndex1 + BlankDate) } ) )
Set the Visible property of the Timer to following:
false /* <-- Hide the Timer control in your app */
Set the DefaultDate property of the End Date Picker to following:
Last(BaseDateRange).Date
Please consider take a try with above solution, then check if the issue is solved.
Best regards,
User | Count |
---|---|
227 | |
101 | |
93 | |
56 | |
30 |
User | Count |
---|---|
288 | |
116 | |
109 | |
62 | |
58 |