cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Issues with Filter Query/AddDates

Hi Guys,

 

I'm having some issues with a filter query from SharePoint.

I'm looking to pull records greater than 60 days old.

 

I've tried:

Created ge '@{addDays(utcNow(),60,'yyyy-MM-dd')}'

Created ge '@{addDays(utcNow(),60,'yyyy-MM-dd')}' and Created lt '@{addDays(utcNow(),90,'yyyy-MM-dd')}'

 

I don't seem to return any data.

 

Any ideas please?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User III
Super User III

It seems to me that you are adding 60 days to the current day, which isn't going to give you any files (because files cannot be created 60 days into the future). Try this instead:

addDays(utcNow(),-60,'yyyy-MM-dd')

It's the same as your expression except the parameter for addDays is -60 and not plus 60

View solution in original post

Looking at your screenshot, you want to show dates after October 30th, 2020.  The Created date of the item in your output is November 10, 2020 which is within your desired criteria.  Are you perhaps confusing the month and days?  The zulu format is year-month-day.  If you are wanting to get all items that are 60 days and OLDER, then you need to use le (less or equal) and not ge (greater or equal) with the -60.

-----------------------------

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

View solution in original post

10 REPLIES 10
Super User III
Super User III

It seems to me that you are adding 60 days to the current day, which isn't going to give you any files (because files cannot be created 60 days into the future). Try this instead:

addDays(utcNow(),-60,'yyyy-MM-dd')

It's the same as your expression except the parameter for addDays is -60 and not plus 60

View solution in original post

Regular Visitor

Hi @Paulie78,

 

Thanks, thats returning data now.

Small problem, it's returning dates for 10/11/2020 which is less than 60.

I only want to return dates 60 day or greater.

(ultimately the flow will delete any records older than 60 days)

Dual Super User II
Dual Super User II

Hi @Penfold623 

 

Odata filter queries working with dates - https://www.youtube.com/watch?v=yeAnuTB85eg&t=814s

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Thanks,
Reza Dorrani, MVP
YouTube
Twitter

 

Resolver II
Resolver II

I think you are going to need to provide more information and show your flow.  I used a Get Items action and on the filter used:

 

Created ge '@{addDays(utcNow(),-3,'yyyy-MM-dd')}'

 

Screenshot 2020-12-29 131652.png

 

I compared that to a filtered list view and I get the same data (using [Today]-3).  I would then do a Compose with a length() function of the output so I could count the number of records and they match.  Please check your list data.  I would encourage you to do some testing with compose and that adddays() expression and compare to the created dates via another compose to ensure you are truly getting apples to apples.  

Regular Visitor

Hi @RezaDorrani,

 

Great video, thanks 🙂

I'm not sure what I'm doing wrong...

 

Filter Query:

Created gt '@{formatDateTime(addDays(utcNow(),-60),'yyyy-MM-dd')}'

 

Filter Results:
Penfold623_0-1609266687722.png

 

Output:

Penfold623_1-1609266723431.png

 

I still seem to be pulling data before 60 days have expired. 

Looking at your screenshot, you want to show dates after October 30th, 2020.  The Created date of the item in your output is November 10, 2020 which is within your desired criteria.  Are you perhaps confusing the month and days?  The zulu format is year-month-day.  If you are wanting to get all items that are 60 days and OLDER, then you need to use le (less or equal) and not ge (greater or equal) with the -60.

-----------------------------

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

View solution in original post

@DAllen365- thanks for that

such a silly mistake 🙂

Oh no worries it happens to us all!  Glad that is all it was.  

@Penfold623  thanks for the feedback and confirming the issue is resolved now.

Looking at your screenshot, you want to show dates after October 30th, 2020.  The Created date of the item in your output is November 10, 2020 which is within your desired criteria.  Are you perhaps confusing the month and days?  The zulu format is year-month-day.  If you are wanting to get all items that are 60 days and OLDER, then you need to use le (less or equal) and not ge (greater or equal) with the -60.

-----------------------------

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

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (25,412)