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:
I have the same question (0)
  • 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 502

#2
Vish WR Profile Picture

Vish WR 454

#3
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

Last 30 days Overall leaderboard