cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jishnu_P_Nair
Regular Visitor

count of Week Days (Mon-Fri ) in a month

Hi Team,

 

Hope all are safe and sound.

I have a query. I need to know how we can find out the count of week days in a month.

like if i have a variable in which i have stored a date, from that date i need to find out in that month how many weekdays are there i.e., how many days are there in that particular month except all Saturdays and Sundays.

 

Looking forward for your suggestions..

 

1 REPLY 1
anupam8555
Responsive Resident
Responsive Resident

Hi Jishnu, 

 

I have created similar flow , please see below steps to get count of weekends of month . 

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')
 

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

image.png

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

 

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 1image.png

9) Now outside 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 this helps you , please mark as verified.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,079)