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 / Using Filter Query for...
Power Automate
Unanswered

Using Filter Query for dates 1 week old and older

(0) ShareShare
ReportReport
Posted on by

Good morning

 

I have an SP list that members add to frequently with a PowerApp. I would like to have a recurring flow that will take all items that are more that 7 days old and 

  • move those items to another list "Archive"
  • Delete these old values in the active list

 

I have a flow similar to this, with the difference being the Filter Query. I don't know the syntax for the date. here is what I have so far.

SAMUELAL_1-1668613094506.png

 

SAMUELAL_0-1668613079988.png

 

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

    Since you want items that are older you want to turn your OData query around

    'Date Returned' lt FormatDateTime(AddDays(UtcNow(), -7),'u')

    That will find all the entries where the Date Returned is prior to 7 days ago.

  • Community Power Platform Member Profile Picture
    on at

    I still receive a "Query not valid" error. I must be missing something else somewhere.

     

    What does the 'u' signify?

  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    I suspect you aren't entering the formatDateTime() and AddDays() functions using the Expressions tab of the dynamic content box.  It looks like you are just typing them in in the screenshot.

     

    The 'u' is the standard ISO8601 universal sortable DateTime format.

  • Ajinder31 Profile Picture
    530 on at

    Hi @Anonymous , If you're not familiar much with expressions then please try following code in Filter query

    'Date Returned' lt '@{formatDateTime(addDays(utcNow(), -7),'u')}'



    --------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • Community Power Platform Member Profile Picture
    on at

    I tried this and got the following error:

    SAMUELAL_0-1668710850728.png

    As you can see it does show a date that is 7 days old, but I don't know why there's a Z at the end of the time stamp

  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    Single quotes shouldn't be around the Field name (Date Returned).  That's why its throwing an error.  That's the display name.  You need to look at the column details to find out what the internal name is and use that.  It won't have quotes and won't have a space in it.

  • Community Power Platform Member Profile Picture
    on at

    Good morning, 

    I made that adjustment and still have the same error

    SAMUELAL_0-1669044357164.png

    SAMUELAL_1-1669044433074.png

    Without the apostrophe on the expression:

    SAMUELAL_3-1669044557967.png

     

     

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    I removed the space in "Date Returned" and the flow worked. I'm not sure why that made a difference

     

    'DateReturned' lt '@{formatDateTime(addDays(utcNow(), -7),'u')}'

     

     

  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    The difference is whether you are using the display name for the column or the internal name.  For OData you need to use the internal name.

  • Community Power Platform Member Profile Picture
    on at

    I guess I was unaware of this and found out unintentionally. Thank you for you help!

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard