Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

Checking if a SharePoint has a file with a certain date in the FileName

I have a SharePoint folder where my team creates and updates a status file every two weeks. Right now I have a Flow setup that automatically copies an empty template and puts the current date on it.


I want to change the flow so that it copies the previous file from two weeks ago so I made a new Flow.


First it does a Sharepoint List Folder on the folder


And then I have an "Apply to Each"

Where it loads SharePoint Body as it was the only option


I do a condition where it compares the SharePoint Name to a GetPastTime Function to see if there is a date in the format. Only it never returns true. I've tried DisplayName, CurrentItem of the Apply to Each, etc but none of them work.


What am I forgetting?



Community Support Team
Community Support Team

Re: Checking if a SharePoint has a file with a certain date in the FileName

Hi @JesseM,


Do you want to copy a previous file that was created two weeks ago?


How is the file named? Is it directly named with the Date? For example, 2018-8-24.


I have made the following test on my side, please take it for a reference.


The file is named with the date, e.g. 2018-8-24. If a file with a name that is two weeks ago, copy and create a new file with the current date as the name in the same folder.


The flow is configured likes below.


The function used in the Condition is:

@contains(formatDateTime(items('Apply_to_each')?['{Name}'], 'yyyy-MM-dd'), formatDateTime(getPastTime(14, 'Day'), 'yyyy-MM-dd'))


In the action Create file, use the current date as the file name, the function is:




Please take a try with it on your side.


Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: Checking if a SharePoint has a file with a certain date in the FileName



Yes the filename has the date it in like 2018-10-12 at the start of the filename.


I'm using the SharePoint List Folder though. My Condition looks like this


@contains(items('Apply_to_each_2')?['Name'], getPastTime(11, 'Day', 'yyyy-MM-dd'))


Helpful resources


Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.


Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.


Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Microsoft Learn

Learn how to build the business apps that you need.


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 73 members 3,491 guests
Please welcome our newest community members: