web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Calculate Date in Powe...
Power Apps
Unanswered

Calculate Date in Power Apps integration with Sharepoint list

(0) ShareShare
ReportReport
Posted on by 997 Super User 2024 Season 1

Hi,

anonymous21_1-1652923895784.png

 

this is my form after integrating Sharepoint list with Power Apps. I need that when the user inputs the StartDate and Total Days Applied, the EndDate will be automatically calculated. The Total days Applied must be excluding the weekends like if the user inputs 10 days, it will only count the weekdays and then return the date. May I know how to do it?

 

anonymous21_2-1652924015638.png

I also have this column that needs to be auto-calculated. Resumen Work Date should be 1 day after the EndDate but skips weekends and public holidays. I tried using the Lookup column in Sharepoint list when creating it but the calculation is amiss and the public holidays are not excluded. How to do this?

 

Is integrating Power Apps with Sharepoint different from Power Apps apps alone? 

 

Thank you.

 

Categories:
  • VaidasG Profile Picture
    469 on at

    Hi @syhrh ,

     

    Why don't you try setting DefaultDate property to DateAdd(StartDate.SelectedDate),Value('Total days applied'),Days)

     

    Regards

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    Hi @VaidasG 

    anonymous21_0-1652942358207.png

    I got this error and I tried putting this formula, DateAdd( DataCardValue2.SelectedDate, DataCardValue15 - 1 ).

    It works but it still counts the weekends. How to not include the weekends?

    Thank you.

  • VaidasG Profile Picture
    469 on at

    @syhrh ,

     

    If(Weekday(DateAdd(StartDate.SelectedDate, Value('Total days applied'.Text),Days)) = 1, // Weekday is Sunday
    DateAdd(StartDate.SelectedDate, Value('Total days applied'.Text)+1,Days),
    If(Weekday(DateAdd(StartDate.SelectedDate,Value('Total days applied'.Text),Days)) = 7, // Weekday is Saturday
    DateAdd(StartDate.SelectedDate,Value('Total days applied'.Text)+2,Days),
    DateAdd(StartDate.SelectedDate,Value('Total days applied'.Text),Days))) // Everything else

    Hope it helps

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @VaidasG I got this error. Even when I change it, the date won't work

    anonymous21_0-1652945520204.png

     

  • VaidasG Profile Picture
    469 on at

    @syhrh ,

     

    Lets work from the back...

    1st error - change 'Total Days Applied' to the name of your input textbox...

    2nd error - function Value has error - this is to do with the 1st error...

    3d error - you have one extra Value function on the first line...

     

    try these...

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @VaidasG I got it! Thank you. For the resume work date, how to skip public holidays? I have a collection from my Sharepoint list that has all public holidays.

    Then, for my end date, how to input days in the total applied days but exclude the weekends? For example, if I input 5 days that start on Thursday(19/5)(the counting begins on Thursday), thus, the end date should be on next Wednesday(25/5) instead of Monday(23/5).

     

    Thank you so much.

  • VaidasG Profile Picture
    469 on at

    @syhrh 

     

    Very top level replay...

     

    • Public holidays - check every day in a day range, if it is In public holiday collection... If so collect day in your temp counter collection... Then add the CountRows(tempCol) to your total days applied value...
    • Weekends - same logic as above, just check week days... if any day in your range is equal to 1 or 7, count days in your temp collection, and then add to the total days applied value...

    Hope this helps

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @VaidasG the formula you gave me works fine in resume work date, it excludes the weekends. So can the same formula be used n the total days applied? I don't really understand what you're saying. Is it easier for the public holiday if it isn't in the Sharepoint list?

    Thank you.

  • VaidasG Profile Picture
    469 on at

    Hi @syhrh 

     

    This is not perfect solution, but I would go with this...

     

    ClearCollect(publicHoliday, DateValue("18/05/2022"),DateValue("19/05/2022"),DateValue("20/05/2022"));

    ClearCollect(counter, Blank()); //Collection to count if any day in the range falls to weekend or public holiday.

    ClearCollect(tempHoliday, ForAll(Sequence(Value('Total days applied'.Text)), {date: DateAdd(StartDate.SelectedDate-1, Value, Days)})); // Generate collection of dates in requested range

    ForAll(tempHoliday As item, // Check if days are weeked or public holiday, if so adds day into extra counter
    If(Or(Weekday(item.date) = 1, Weekday(item.date) = 7, item.date in publicHoliday), Collect(counter, item)));


    //EndDate
    DateAdd(StartDate.SelectedDate, Value('Total days applied'.Text)+CountRows(counter),Days)

     

    Hope this helps

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @VaidasG 

    I input the below code on the App-> OnStart property

    ClearCollect(publicHoliday, DateValue("06/06/2022"),DateValue("7/8/2022"),DateValue("7/11/2022"), DateValue("8/31/2022"),DateValue("9/16/2022"),DateValue("10/24/2022"),DateValue("12/26/2022"));
    
    ClearCollect(counter, Blank()); //Collection to count if any day in the range falls to weekend or public holiday.
    
    ClearCollect(tempHoliday, ForAll(Sequence(Value(DataCardValue15.Text)), {date: DateAdd(DataCardValue2.SelectedDate-1, Value, Days)})); // Generate collection of dates in requested range
    
    ForAll(tempHoliday As item, // Check if days are weeked or public holiday, if so adds day into extra counter
    If(Or(Weekday(item.date) = 1, Weekday(item.date) = 7, item.date in publicHoliday), Collect(counter, item)));

    Then I input, this into the EndDate input value but it still counts the weekends

    DateAdd(DataCardValue2.SelectedDate, Value(DataCardValue15.Text)+CountRows(counter),Days)

     It still counts the weekends and holidays.

     

    I used the above formula (your second post) on the Resume Work Date and it doesn't count the weekends. then I put it on the EndDate as well but the weekends are still counted.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 204 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard