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 / Subtracting Days Until...
Power Automate
Answered

Subtracting Days Until Last Friday

(0) ShareShare
ReportReport
Posted on by 158

Hello,

 

I am trying to obtain the date of the last Friday of August by iteratively subtracting day-by-day starting from the date 09-01-2023. The issue is that the "Subtract from time" action only works in the first iteration of the loop, so it subtracts a day from September 1st to get October 31st, but then it stops subtracting. Why does the subtraction only work when used in a loop?

Screenshot 2023-08-30 at 8.49.27 PM.pngScreenshot 2023-08-30 at 8.59.20 PM.png

 

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @OnurOnal 

     

    Do until works until the condition is met, and it runs once 

     

    Check this 

     

    https://www.acuitytraining.co.uk/news-tips/power-automate-do-until/

     

    Also regarding your question, it should execute until LastFridayFound equals true so your condition should be true instead of false

    Nived_Nambiar_0-1693449304820.png

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • OnurOnal Profile Picture
    158 on at

    @Nived_Nambiar,

     

    I changed it to true but the same thing happens again. It stops subtracting days after August 31st.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @OnurOnal 

     

    I think your condition is reffering to old date, not the output from subtract from date action 

     

    Could you show what is the expression you have written in condition ?

    Nived_Nambiar_0-1693450188804.png

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • OnurOnal Profile Picture
    158 on at

    @Nived_Nambiar,

     

    The condition derives the day of the week from the date. 

     

    Screenshot 2023-08-30 at 9.53.34 PM.png

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @OnurOnal 

     

    The reason why bot stops now after one iteration is because in condition you are still considering Date Variable Date for condition which still holds the first month value (in your case: 1st September 2023). So in the condition you have to take the Calculated time dynamic content which is output of Subtract from time shown like below

    Nived_Nambiar_0-1693450739300.png

     

    then expression would be like this 

     
    So instead of variables('Date') in your expression replace it with body('Subtract_from_time'
     
    Let me know whether it helps you 
     
    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • OnurOnal Profile Picture
    158 on at

    @Nived_Nambiar,

     

    I tried the following expression but nothing changes.

     

    Screenshot 2023-08-30 at 11.05.50 PM.png

  • OnurOnal Profile Picture
    158 on at

    @Nived_Nambiar,

     

    Is there another way to subtract a day without having to use the "Subtract from time" action?

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @OnurOnal 

     

    After subtract from date action , could you use set variable action to update Date variable with value Calculated Time which is output from Subtract from Date action.

     

    I forget to mention the point. 

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • OnurOnal Profile Picture
    158 on at

    @Nived_Nambiar,

     

    This doesn't work either.

     

    Screenshot 2023-08-30 at 11.18.13 PM.png

  • Verified answer
    Manish Solanki Profile Picture
    15,167 Moderator on at

    Hi @OnurOnal 

     

    Pls refer the below snippet, it may help you:

    ManishSolanki_0-1693458160972.png

    ManishSolanki_1-1693458287162.png

    Expression which are highlighted in above screenshots are:

    formatDateTime(addDays(triggerBody()['date'],mul(variables('Counter'),-1)),'dddd','en-us')
    addDays(triggerBody()['date'],mul(variables('Counter'),-1))

     

    I have also attached the flow here so that you can test it and make changes as per your need. You can make it a child flow if you can want to reuse this logic in multiple flows.

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard