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

Using Filter Query for dates 1 week old and older

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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
    69,110 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
    Microsoft Employee 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
    69,110 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
    Microsoft Employee 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
    69,110 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
    Microsoft Employee 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
    Microsoft Employee 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
    69,110 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
    Microsoft Employee 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

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!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard