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 / DateAdd excluding week...
Power Apps
Answered

DateAdd excluding weekends

(0) ShareShare
ReportReport
Posted on by 96

I have an app that uses date pickers. There are actually 11 date pickers that require different dates. My primary date picker DataCardValue8 is the basis for the calculations for all the other date pickers. Some date pickers will add 1 day, others 5 days, while still others 10 days. I'll have to duplicate the formula on each individual date picker. What I want is to exclude weekends so I always end up with a business day in the date picker.

 

I came across a solution that looks plausible, but when applying it in my PowerApps, I get an error. The error states that the function DateAdd has some invalid arguments... Can someone help me get this working or suggest a different way to solve my problem?

Here is the code that I am using in my DefaultDate for one of the subsequent date pickers (in this example I am adding 5 days). I found the code at the following link: https://www.matthewdevaney.com/how-to-add-business-days-to-a-date-in-power-apps-excludes-weekends/ 

 

With(
{
varStartDate: DataCardValue8.SelectedDate,
varAddWeekdays: 5
},
DateAdd(
varStartDate,
Value(varAddWeekdays) + RoundDown(
(Weekday(
varStartDate,
Monday
) + Value(varAddWeekdays) - 1) / 5,
0
) * 2,
Days
)
)

Categories:
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @adove, 😊

     

    Older code examples may still mention enums simply by value such as Days and Monday in your code example. Currently you will also have to reference the enum type. In your case replace the following parts of your code:

     

    • Days -> TimeUnit.Days
    • Monday -> StartOfWeek.Monday

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Lavanya11 Profile Picture
    13 on at

    why its showing an error like sequence should be in between 0 to 50000

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

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard