cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mokhawaja
Level 8

Fliter an entity in CDS using odata on a date = yesterday

Hi,

i am trying to filter an entity based a date field... but with no success, i am trying to get all records that haver the date of "yesterday"

 

i.e.: ReportDate=yesterday

 

where ReportDate is the date field!

Screenshot (1).png

 

 

really appreciate your help on this.

 

Regards,

Mohammad

3 REPLIES 3
Highlighted
Community Support Team
Community Support Team

Re: Fliter an entity in CDS using odata on a date = yesterday

Hi mokhawaja,

 

About Odata filter query, please take this documentation for a reference:
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-odata-query-operations-in-sharepoint-...

 

From the doc we know that when filter the datetime, we need to get the day, month and year of the date.

 

While you could also add a Condition in your flow to filter the date which is equal to yesterday.


To test this issue, I configured the flow likes below. It works as expected.


The function I use in the Condition is: @equals(items('Apply_to_each')?['date'], formatdatetime(adddays(utcnow(),-1),'yyyy-MM-dd'))

3.PNG

 

Reference documentation:
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

 

Please try it on your side. Hope this could be a reference for you.

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.
mokhawaja
Level 8

Re: Fliter an entity in CDS using odata on a date = yesterday

hi @v-yamao-msft,

thank you for your suggestion, which was partially successful, but the problem that my entity that i am trying to filter contains more than 2000 records and the flow times out most of the time with no success.

so i believe that the best way is to use the odata filter... but i still could not find the formula that i can use with success... and most of the time i get a syntax error.

 

i could extract the date of yesterday using the action (Get Past time) before trying to filter... but my probelm is what is the formula for this Odata filter?

 

appreciate your help.

Mohammad

MOIZA
Level: Power Up

Re: Fliter an entity in CDS using odata on a date = yesterday

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

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (5,021)