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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Count number of date r...
Power Automate
Answered

Count number of date range exclude weekend

(0) ShareShare
ReportReport
Posted on by 50

Hi, I created a flow for counting the differences between days. But when I run the flow, the variable in the Increment variable does not start counting 1 in 2023-01-03 but it continues count from the 2023-01-05 and return the results obtained on 2023-01-03 plus the old date. 

 

How can I solve the flow so that it works properly? ,Thank you 🙏🏼.

 

Flow :

4DA7248F-E81E-40B7-A214-90C3455A4DE5.jpeg

AE3CCF5E-DA3B-4949-9AC2-A04913CDB955.jpeg

70D567B0-7039-4390-A052-58561DC952EA.jpeg

D8F89B0B-5DB6-4D1B-ABE4-99FA7E1BE537.jpeg

6EEED9DB-0273-4EEC-BA84-FF542F452DF9.jpeg


Result :

1928E9C5-67AF-43B2-96BC-900DA5ED2B5F.jpeg

Problems part :

in 2023-01-05

7ABB179C-F4C7-4373-AB9D-2E16774DA262.jpeg

 

in 2023-01-03

742A0E19-A206-4E8A-B152-76039300D105.jpeg

Categories:
I have the same question (0)
  • Verified answer
    Chriddle Profile Picture
    8,443 Super User 2025 Season 2 on at

    I would prefer Select and Filter actions over Apply to teach and Condition.

     

    Chriddle_0-1678900164084.png

    DayDiff: Compose Action with expression:

     

    div(sub(ticks(outputs('EndDate')), ticks(outputs('StartDate'))), 864000000000)

     

     

    DayArray: Select action:

    From:

     

    range(1,outputs('DayDiff'))

     

    Map:

     

    addDays(outputs('StartDate'), item())

     

     

    WorkDays: Filter action

    From:

     

    body('DayArray')

     

    Filter:

     

    @And(greater(dayOfWeek(item()), 0), less(dayOfWeek(item()), 6)) 

     

     

    CountWorkDays: Compose action

     

    length(body('WorkDays'))

     

     

    This counts from StartDate+1 up to and including EndDate.

  • YanisaSC Profile Picture
    50 on at

    Flow works amazingly!!! .

     

    I've been trying to solve this problem for a week. Thank you very much for helping me.💖

  • Chriddle Profile Picture
    8,443 Super User 2025 Season 2 on at

    You're welcome.
    I also considered creating a version in which the number of days is determined directly using a formula.
    However, the flow above is more flexible since you get a date array.
    For example, you can use it to easily filter for public holidays, visualize the days in a table or calendar, or calculate the hours if they depend on the day of the week.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard