Skip to main content
Power Automate
    • Connectors
    • Templates
    • Digital process automation
    • Robotic process automation
    • Business process automation
    • Process advisor
    • AI Builder
  • Pricing
  • Partners
    • Blog
    • Documentation
    • Roadmap
    • Self-paced learning
    • Webinar
    • Business process and workflow automation topics
    • Overview
    • Issues
    • Give feedback
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • User groups
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Microsoft Power Automate Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power Automate
    • General Power Automate Discussion
    • Using Connectors
    • Building Flows
    • Using Flows
    • Power Automate Desktop
    • Process Advisor
    • AI Builder
    • Power Automate Mobile App
    • Translation Quality Feedback
    • Connector Development
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Galleries
    • Community Connections & How-To Videos
    • Webinars and Video Gallery
    • Power Automate Cookbook
    • Events
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Community Engagement
    • Community AMA
    • Community Blog
    • Power Automate Community Blog
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power Automate Community
    • Galleries
    • Power Automate Cookbook
    • Find Working Days of Month

    Find Working Days of Month

    05-24-2020 03:41 AM

    anupam8555
    Continued Contributor
    1732 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    anupam8555
    anupam8555 Continued Contributor
    Continued Contributor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Find Working Days of Month

    ‎05-24-2020 03:41 AM

    Hello folks, 

    As there are not any OOB endpoint for getting working days of a month or date range. I have created this flow to get working days i.e. excluding Saturday and Sunday of Month. You can customize according to you needs.

    Follow below steps :

    1) Compose action to set start date of month

    image.png

    2) create compose action again to set end date of month using following expression :

    subtractFromTime(startOfMonth(addToTime(outputs('Compose'),1,'Month')),1,'Day')
     
    image.png
     

    3) Initialize variable to set Start_Date as string and value of output #1 compose

     

    4) Initialize an array - as array output of #1 compose . This is going to be used to loop through between date rang

     

    5) Initialize weekend incremental counter variable 

    image.png

    6) Create Do Until loop - set 'Start_Date' and compare output value with 'Compose_3' i.e. #2 step

     
    •  Create compose action again to add 1 day into start date with expression as follows : addDays(variables('Start_Date'),1)
    •  Now add action to set variable value of 'Start_Date' from previous compose output
    •  Add append to array variable - Select 'Date_Array' with value of 'Start_Date' - This is going to append array variable 

    image.png

    7) Now after Do until, create action to compose array output for 'Date_Array'

     
     

    image.png

     
     

    Add apply to each loop - This is going to iterate through each dates we added in 'DateArray'

    • Add conditions in each loop to check day is weekend or not using following condition : (Use OR)
      dayOfWeek(items('Apply_to_each')) is equal to 6
      dayOfWeek(items('Apply_to_each')) is equal to 0
    • In Yes action , Increment Weekend variable to 1
       

    image.png

    9) Now After apply to each , create a new compose action with input of 'Weekend'. This is going to show you number of weekends of month.

    image.png

    10) Check using flow checker & Test.

     

    If you have any questions or concerns , please feel free to reach out to me. 

    Preview file
    28 KB
    FindWorkingDaysofaMonth_20200524100627.zip
    Labels:
    • Labels:
    • Automated Flows
    • Button flows
    • Scheduled flows
    Message 1 of 2
    1,732 Views
    0 Kudos
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    RJF61
    RJF61 Post Partisan
    Post Partisan
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎10-06-2022 07:40 AM

    Hello @anupam8555 

    I am attempting to use the Flow you have provided but am stuck on Item 4 (Initialize an array).  When I use the Output of #1 Compose, I receive an error...

     

    The variable 'DateArray' of type 'Array' cannot be initialized or updated with value of type 'String'. The variable 'DateArray' only supports values of types 'Array'.

     

    Based on the steps provided, Compose #1 is a date.

     

    I realize this is an older posting but wondered if you could assist?

    Thanks

     

     

     

    Message 2 of 2
    516 Views
    0 Kudos
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign up free
    • Sign in

    Browse

    • Templates
    • Connectors
    • Partners

    Downloads

    • Mobile
    • Gateway

    Learn

    • Documentation
    • Learn
    • Support
    • Community
    • Give feedback
    • Blog
    • Pricing

    • © 2023 Microsoft
    • Contact us
    • Trademarks
    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Terms & conditions
    California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices