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 / Revise DateDiff Formula
Power Apps
Answered

Revise DateDiff Formula

(0) ShareShare
ReportReport
Posted on by 299

Morning @phipps0218  and @WarrenBelz ,

You both helped me resolve my DateDiff issue and your solutions are working perfectly! However, another option, Work Travel, was added to the 'Reason for Request' Choice column. My Ops Manager does not want Work Travel calculated as PTO. When Work Travel is selected the '# of Days Requested' field should remain 0 or blank. I have tried adding the If statements below, but none work as needed. I've added them to the beginning of the formula, middle and end and no change. Can I incorporate this request into the existing formula or would it be better to create a separate field for the Work Travel option?

Thanks again for your help!

Patti

 

Existing formula on Default property of the '# of Days Requested' field:

If(
IsBlank(dcStartDate.SelectedDate) || IsBlank(dcEndDate.SelectedDate),
0,
With(
{
wHol: Filter(
CalHolidays,
HolidayDate >= dcStartDate.SelectedDate && HolidayDate <= dcEndDate.SelectedDate
)
},
RoundDown(
DateDiff(
dcStartDate.SelectedDate,
dcEndDate.SelectedDate,
Days
) / 7,
0
) * 5 + Mod(
5 + Weekday(dcEndDate.SelectedDate) - Weekday(dcStartDate.SelectedDate),
5
) - CountRows(wHol) + 1
)
)

 

If statements I've tried to incorporate into the existing formula:

  • If(LeaveReason.Selected.Value = "Work Travel", "DaysRequested", 0)
  • If("Work Travel" in LeaveReason.Selected.Value,true,false, 0)
  • If(LeaveReason.Selected.Value, "Work Travel"),true, 0)

paPTODates5.png

Categories:
  • Verified answer
    MVP-Phipps Profile Picture
    3,521 Super User 2024 Season 1 on at

    If(LeaveReason.Selected.Value = "Work Travel", 0, If(
    IsBlank(dcStartDate.SelectedDate) || IsBlank(dcEndDate.SelectedDate) && LeaveReason.Selected.Value <> "Work Travel",
    0,
    With(
    {
    wHol: Filter(
    CalHolidays,
    HolidayDate >= dcStartDate.SelectedDate && HolidayDate <= dcEndDate.SelectedDate
    )
    },
    RoundDown(
    DateDiff(
    dcStartDate.SelectedDate,
    dcEndDate.SelectedDate,
    Days
    ) / 7,
    0
    ) * 5 + Mod(
    5 + Weekday(dcEndDate.SelectedDate) - Weekday(dcStartDate.SelectedDate),
    5
    ) - CountRows(wHol) + 1
    )
    )


    Just check there is enough brackets but this should work.

    Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful as can help others.

    LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
    YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
    Twitter: https://twitter.com/phipps0218

  • PVLove Profile Picture
    299 on at

    @phipps0218 

    Worked like a charm, thank you so much!

    Patti

  • MVP-Phipps Profile Picture
    3,521 Super User 2024 Season 1 on at

    Anytime!

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 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard