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 / Delete Files in ShareP...
Power Automate
Unanswered

Delete Files in SharePoint Folder based on LastModified - X Days

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

 

I am building a flow to delete files on a SharePoint folder based on the date Last Modified - X Days.

I used the following approach as a guideline: https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Delete-files-older-than-X-days-from-OneDrive-using-Flow/ba-p/368561

 

alberto1_1-1630089687704.png

 

However it seems I am getting a wrong output in the LastModified field as per screenshots: "0001-01-01T00:00:00"

 

 

alberto1_0-1630089638052.png

 

 

Am I using the correct field for this purpose?

 

Can anyone assist?  

 

Thank you!

Categories:
I have the same question (0)
  • kierian Profile Picture
    Microsoft Employee on at

    Solved: Delete files older than 3 years - Power Platform Community (microsoft.com)

    try this

    hope this help.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    So I replicated that flow, but it doesn't seem to be doing anything:

     

    alberto1_0-1630096354015.png

    alberto1_1-1630096461018.png

     

    Were you able to replicate it?
    Any ideas?

     

     

  • v-LilyW-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous 

    Has your problem been solved?

    If you want to delete a file based on it's modified date , you can refer to the following screenshots.

    I have a folder like this:

    vLilyWmsft_0-1630290943528.png

    Flow in details:

    vLilyWmsft_1-1630290943531.png

    vLilyWmsft_2-1630290943534.png

    Expression: formatDateTime(items('Apply_to_each')?['Modified'],'yyyy-MM-dd')

    Expression: addDays(utcNow(),-7,'yyyy-MM-dd')

    vLilyWmsft_3-1630290943538.png

     

    After flow runs, the files will be deleted.

    vLilyWmsft_4-1630290987405.png

    Hope the content above may help you.

    Best Regards

    If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It doesn't seem to work for me. I'm getting that the flow is running successfully, but nothing is getting deleted; I still have files from January...

     

    Not sure what is going on...

     

    alberto1_0-1630589392338.pngalberto1_1-1630589465749.png

     

    formatDateTime(items('Apply_to_each')?['Modified'],'yyyy-MM-dd')
    addDays(utcNow(),-7,'yyyy-MM-dd')

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
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard