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 / Exclude the weekends
Power Apps
Answered

Exclude the weekends

(0) ShareShare
ReportReport
Posted on by 341

Hi 

 

How do I the exclude the weekends from the formula below?

MiteshGovan_0-1619197280109.png

Text(DateAdd(DatePicker2.SelectedDate, Value(Date_Estimator_LBL.Text), Days),DateTimeFormat.LongDate)

 

Thank you.

Categories:
  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    Are you looking to exclude weekends from the days added to the selected date, or choose the first weekday after adding the days to the selected date? For example, if SelectedDate is 2021-04-09 (Friday) and Value(Date_Estimator_LBL.Text) is 8, do you want the result to be 2021-04-21 (Wednesday, 8 non-weekend days after 2021-04-09) or 2021-04-19 (Monday, first weekday after selecteddate+value)? Or something else?

  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    If you want to exclude weekends from the days added to the date, you can use an expression like this (it currently doesn't work if the selected date on the date picker is on a weekend, but can be adjusted if this is a problem):

    With(
     { weekDaysToAdd: Value(Date_Estimator_LBL.Text) },
     With(
     {
     fullWeeks: RoundDown(weekDaysToAdd / 5, 0),
     remainingDays: Mod(weekDaysToAdd, 5),
     daysToWeekend: 5 - Weekday(DatePicker1.SelectedDate, StartOfWeek.Monday)
     },
     With(
     { daysToAdd: fullWeeks * 7 + remainingDays + If(remainingDays > daysToWeekend, 2, 0) },
     DateAdd(DatePicker1.SelectedDate, daysToAdd))))

    Or if you want to get the first weekday after adding the days:

    With(
     { dateAfterAdd: DateAdd(DatePicker1.SelectedDate, Value(Date_Estimator_LBL.Text)) },
     With(
     { weekday: Weekday(dateAfterAdd, StartOfWeek.Sunday) },
     DateAdd(dateAfterAdd, If(weekday = 1 /* Sunday */, 1, weekday = 7 /* Saturday */, 2, 0))))

    Hope this helps!

  • MiteshGovan Profile Picture
    341 on at

    Hi

     

    Thank you. How do I add Long Date to both of the formula's.

     

    Kind Regards,

  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You can use the Text function at the date result of the With function:

    With(
     { weekDaysToAdd: Value(Date_Estimator_LBL.Text) },
     With(
     {
     fullWeeks: RoundDown(weekDaysToAdd / 5, 0),
     remainingDays: Mod(weekDaysToAdd, 5),
     daysToWeekend: 5 - Weekday(DatePicker1.SelectedDate, StartOfWeek.Monday)
     },
     With(
     { daysToAdd: fullWeeks * 7 + remainingDays + If(remainingDays > daysToWeekend, 2, 0) },
     Text(DateAdd(DatePicker1.SelectedDate, daysToAdd), DateTimeFormat.LongDate))))

    or

    With(
     { dateAfterAdd: DateAdd(DatePicker1.SelectedDate, Value(Date_Estimator_LBL.Text)) },
     With(
     { weekday: Weekday(dateAfterAdd, StartOfWeek.Sunday) },
     Text(
     DateAdd(dateAfterAdd, If(weekday = 1 /* Sunday */, 1, weekday = 7 /* Saturday */, 2, 0)),
     DateTimeFormat.LongDate)))

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard