cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
joel914823
Helper III
Helper III

Not Equal to today

Im trying to filter query for get items from sharepoint so that it does not get items that are equal to today.

 

The format when it pulls from sharepoint is as such.   

"Created":"2022-11-07T12:06:55Z"

How can I write the filter query to it excludes those items, I've tried to format in the expression but with no luck.  Thank you. 

1 ACCEPTED SOLUTION

Accepted Solutions

Then Scott is right that you only need the less than.  But I would still use the Compose to get the full dateTime in ISO8601 format for midnight. In my experience the comparisons don't work correctly if you aren't using full ISO 8601 format.  So try it with the first Compose I had in my screenshot and set Created lt that compose value.



-------------------------------------------------------------------------
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
ScottShearer
Super User
Super User

@joel914823 

Try this for your filter query:

Created lt 'formatDateTime(utcNow(), 'yyyy-MM-dd')'

 

Obviously, the formatDateTime() expression must be entered inside of the expression window.

image.png

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

Scott
Pstork1
Dual Super User
Dual Super User

Because it includes the time component you can't really use equals.  What you need to do is provide a range. Test it for Created is less that today at midnight and Created is greater than yesterday at midnight.

 



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

@Pstork1 Thank you that makes sense on the range vs. equal.  Pardon my lack in knowledge but how do I put today at midnight and yesterday at midnight?  your guidance is appreciated.

The easiest way is to use a Compose and populate it with Yesterday at Midnight (which is today at 00:00).  Then another Compose to AddDay(midnight,1) to it for today.  Here's a screenshot of an example

image.png



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

@Pstork1 @joel914823 

If the objective is to exclude items that were not created today, I believe that the expression that I posted above will work (time zone not withstanding).

Created lt 'formatDateTime(utcNow(), 'yyyy-MM-dd')'

 

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

Scott
joel914823
Helper III
Helper III

@ScottShearer Hi Scott - thanks for your reply.  I tried that but it still included it in the get items output.  It may be that utc now its taking into consideration at that moment the flow runs vs a range of time (best guess)

I may have read it wrong.  I thought he was trying to include only the items created or modified today.



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

@Pstork1 I'm looking to exclude items created today

Then Scott is right that you only need the less than.  But I would still use the Compose to get the full dateTime in ISO8601 format for midnight. In my experience the comparisons don't work correctly if you aren't using full ISO 8601 format.  So try it with the first Compose I had in my screenshot and set Created lt that compose value.



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

That worked, thank you both! @Pstork1 @ScottShearer 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (2,202)