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 Automate / Count the number of Mo...
Power Automate
Unanswered

Count the number of Mondays between two dates?

(0) ShareShare
ReportReport
Posted on by 33

Is it possible to count the number of Mondays between two dates? 

Categories:
I have the same question (0)
  • lbendlin Profile Picture
    8,649 Super User 2026 Season 1 on at

    Yes.  What have you tried and where are you stuck?

  • v-yetonggu-msft Profile Picture
    Microsoft Employee on at

    Hi @BriH ,

    I thought this link would be helpful to you and I did a test for your reference.

    Finding Number Of Working Days Between Two Dates Using Power Automate Flow (c-sharpcorner.com)

    In my scenario:

    The Result:

    vyetonggumsft_4-1713837325804.png

    My Flow :

    vyetonggumsft_1-1713836926693.png

    outputs('Compose_StartDate')
    array(outputs('Compose_StartDate'))

    vyetonggumsft_2-1713837083779.png

    outputs('Compose_EndDate')
    addDays(variables('IndexDate'),1,'yyyy-MM-dd')
    outputs('Compose')

    vyetonggumsft_3-1713837216668.png

    dayOfWeek(items('Apply_to_each'))

    Best Regards,

    Sunshine Gu

  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at

    Chriddle_0-1713876839275.png

    Compose

    {
    "Start": "2024-04-01",
    "End": "2024-04-22"
    }

     

    Filter array

    From:

    range(
    	0,
    	add(
    		int(
    			first(
    				split(
    					dateDifference(
    						outputs('Compose')['Start'],
    						outputs('Compose')['End']
    					),
    					'.'
    				)
    			)
    		),
    		1
    	)
    )

    Filter:

    dayOfWeek(
    	addDays(
    		outputs('Compose')['Start'],
    		item()
    	)
    )

    is equal to

    1

     

    Compose 2

    length(body('Filter_array'))

     

    Chriddle_1-1713876995145.png

     

  • lbendlin Profile Picture
    8,649 Super User 2026 Season 1 on at

    I would convert the dates to Integer, create the range , and then filter the array by modulo 7.

     

    @BriH Can you please define what you mean by "between"  (ie is it inclusive or exclusive of the range borders) and can you describe what the format of your dates is? Some sample data maybe?

  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at

    Also tried another approach using the same Compose as above:

     

     

    {
     "Start": "2024-04-01",
     "End": "2024-04-14"
    }

     

     

     

    Chriddle_0-1713882160519.png

    Compose 2

    "Fullweeks":

     

     

    div(
    	add(
    		int(
    			first(
    				split(
    					dateDifference(
    						outputs('Compose')['Start'],
    						outputs('Compose')['End']
    					),
    					'.'
    				)
    			)
    		),
    		1
    	),
    	7
    )

     

     

    "AdditionalDays":

     

     

    mod(
    	add(
    		int(
    			first(
    				split(
    					dateDifference(
    						outputs('Compose')['Start'],
    						outputs('Compose')['End']
    					),
    					'.'
    				)
    			)
    		),
    		1
    	),
    	7
    )

     

     

    "StartDay":

     

     

    dayOfWeek(outputs('Compose')['Start'])

     

     

     

    Compose 3

     

     

    add(
    	outputs('Compose_2')['FullWeeks'],
    	if(
    		if(
    			greater(
    				outputs('Compose_2')['StartDay'],
    				1
    			),
    			greater(
    				add(
    					outputs('Compose_2')['StartDay'],
    					outputs('Compose_2')['AdditionalDays']
    				),
    				7
    			),
    			greater(
    				outputs('Compose_2')['AdditionalDays'],
    				0
    			)
    		),
    		1,
    		0
    	)
    )

     

     

     

    Of course you can combine Compose 2 and Compose 3 to one big expression

    Spoiler (Highlight to read)
    add(
    	div(
    		add(
    			int(
    				first(
    					split(
    						dateDifference(
    							outputs('Compose')['Start'],
    							outputs('Compose')['End']
    						),
    						'.'
    					)
    				)
    			),
    			1
    		),
    		7
    	),
    	if(
    		if(
    			greater(
    				dayOfWeek(outputs('Compose')['Start']),
    				1
    			),
    			greater(
    				add(
    					dayOfWeek(outputs('Compose')['Start']),
    					mod(
    						add(
    							int(
    								first(
    									split(
    										dateDifference(
    											outputs('Compose')['Start'],
    											outputs('Compose')['End']
    										),
    										'.'
    									)
    								)
    							),
    							1
    						),
    						7
    					)
    				),
    				7
    			),
    			greater(
    				mod(
    					add(
    						int(
    							first(
    								split(
    									dateDifference(
    										outputs('Compose')['Start'],
    										outputs('Compose')['End']
    									),
    									'.'
    								)
    							)
    						),
    						1
    					),
    					7
    				),
    				0
    			)
    		),
    		1,
    		0
    	)
    )
    add( div( add( int( first( split( dateDifference( outputs('Compose')['Start'], outputs('Compose')['End'] ), '.' ) ) ), 1 ), 7 ), if( if( greater( dayOfWeek(outputs('Compose')['Start']), 1 ), greater( add( dayOfWeek(outputs('Compose')['Start']), mod( add( int( first( split( dateDifference( outputs('Compose')['Start'], outputs('Compose')['End'] ), '.' ) ) ), 1 ), 7 ) ), 7 ), greater( mod( add( int( first( split( dateDifference( outputs('Compose')['Start'], outputs('Compose')['End'] ), '.' ) ) ), 1 ), 7 ), 0 ) ), 1, 0 ) )

     

     

  • lbendlin Profile Picture
    8,649 Super User 2026 Season 1 on at

    Compose:

    {
    "Start": "2024-04-01",
    "End": "2024-04-14"
    }

    Filter Array:

    range(
    div(sub(ticks(outputs('Compose')['Start']),ticks('1899-12-30T00:00:00')),864000000000),
    add(div(sub(ticks(outputs('Compose')['End']),ticks(outputs('Compose')['Start'])),864000000000),1)
    )

    by:

    mod(item(),7) is equal to 2

     

    Returns two rows.

  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at

    @lbendlin Nice one

    Although I don't like your reference date  because it reminds me of the Excel nonsense
    😉

    https://xkcd.com/2676/

     

    • '0001-01-01T00:00:00' would be sensible since this is in the definition of ticks
    • A Sunday such as “1970-01-04T00:00:00” also has its advantage. Here determining the number in the filter is more intuitive.
  • lbendlin Profile Picture
    8,649 Super User 2026 Season 1 on at

    Guilty as charged. I used the Power BI date "logic". The starting point doesn't matter as long as you know it's modulo.

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!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard