web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / subtractFromTime not w...
Power Automate
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

 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    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)
  • franzerman Profile Picture
    10 on at

    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
    68,697 Most Valuable Professional on at

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard