Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

subtractFromTime not working

(0) ShareShare
ReportReport
Posted on by 10

Hi!

 

I have an Excel table with dates (column called "endDate"), and I want to know which dates are on the current week. For that I'm using the following OData filter query:

 

(endDate ge startOfWeek) and (endDate lt startOfNextWeek)

 

 

 

where startOfWeek is the following piece of dynamic content:

 

subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), "Day")

 

 

and startOfNextWeek is pretty similar, but adding 7 days to mark the start of the next week:

 

addDays(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), "Day"), 7)

 

 

The problem I'm getting is with subtractFromTime. If I add the "Day" parameter, I will get the error "The expression is invalid". If I don't include that parameter, I won't get that error but the flow won't run because subtractFromTime is lacking a parameter.

 

Is it a problem with Power Automate? Is there a problem with my filter I'm not seeing?

 

Thanks in advance

 

  • Pstork1 Profile Picture
    67,060 Most Valuable Professional on at
    Re: subtractFromTime not working

    With error checking the update function can be a bit quirky at times.  But I have no specific explanation other than that.  I do know that you have to use the single quote instead of the double quote.  I catch myself doing it inadvertently all the time.

  • franzerman Profile Picture
    10 on at
    Re: subtractFromTime not working

    Thanks for your response, this in fact seems to be the problem. But now it has raised 2 more issues, maybe you could know something about them.

     

    Issue #1: Changed "Days" to 'Days', tried to save and got the same error ("The expression is invalid"). After that I did nothing and tried to save the expression again and worked just fine. Why is that?

     

    Issue #2: When I tried to update the other "Day" to 'Day' (because I have 2 in my filter) it didn't show the error the first one had showed, but after saving I checked it and it hadn't really updated, it just saved as the old version ("Day" instead of 'Day'). I updated it again and it worked just fine. Are these normal bugs when working with Power Automate?

     

    Thanks

  • Pstork1 Profile Picture
    67,060 Most Valuable Professional on at
    Re: subtractFromTime not working

    Its a very simple fix.  You overlooked that you are writing the formula as JSON so it needs to use 'Day' not "Day".  Change the double quotes to single quotes and it will work.  I missed it myself for a few minutes.

    addDays(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), 'Day'), 7)

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