Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Get days inbetween two dates

(0) ShareShare
ReportReport
Posted on by 24

Hey guys,

 

I am currently improving a workflow of a holiday approval tool.

I am stuck at a particular problem. That is, the planner currently includes weekends into the "# of days of paid leave".

 

The employees enter the start date of their desired vacation and the end date.

What I want to do is with a foreach-Loop to evaluate each day with the "DayOfWeek" function to see whether it's a saturday or sunday and subtract these two days. So let's say an employee wants to have 7 days of vacation, only 5 days should be subtracted from his "yearly paid leave contingent".

 

Question: How can I "fill in the gaps" between start and end date?

 

Kind Regards

 

Sascha

  • SaschaSchroeder Profile Picture
    24 on at
    Re: Get days inbetween two dates

    Hi Yueyun,

    thank you very much for your reply,

    I tried to implement it but it doesn't quite work.

     

    The Flow Trigger is a line added to a Sharepoint list, and I tried everything that I came uo with, but your first code gives me an error:

     

    InvalidTemplate
    Unable to process template language expressions in action 'Get_Dates' inputs at line '0' and column '0': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

     

    The type of the columns in the sharepoint list is "Time/Date".

    What do I have to change?

  • v-yueyun-msft Profile Picture
    on at
    Re: Get days inbetween two dates

    Hi , @SaschaSchroeder 

    According to your description, you want to extract the workdays from  the start date and the end Date.

    I test it in my side , this is my test flow:

    vyueyunmsft_0-1706146077054.png

     

     

    range(0,add(int(split(dateDifference(triggerBody()['date'],triggerBody()['date_1']),'.')[0]),1))
    addDays(triggerBody()['date'],item())
    @and( not(equals(dayOfWeek(item()), 6)) , not(equals(dayOfWeek(item()), 0)) )
     
    And this is the result :
    vyueyunmsft_1-1706146116553.png

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1