0

I have tried this REST API and I got one item correctly:

https://****.sharepoint.com/sites/test/_api/web/lists/getbytitle('ListData')/items?$filter=ExpiryDate eq '2023-04-25' or ExpiryDate eq '2023-05-11' or ExpiryDate eq '2023-06-10'

enter image description here

But if I type this date I will only get one item although I have more than 300 items which should match this criteria:

https://****.sharepoint.com/sites/test/_api/web/lists/getbytitle('ListData')/items?$filter=ExpiryDate eq '2023-04-25' or ExpiryDate eq '2023-05-11' or ExpiryDate eq '2023-06-07'

enter image description here

So what could be the issue?

3 Answers 3

1

I think the issue might be that the date filter uses ISOSTRING format.

So "ExpiryDate eq datetime'2023-05-11T00:00:00.000Z'" instead of "ExpiryDate eq '2023-05-11'"

Example: REST API filter by start and end dates using 'today'

1
0

You can use PNP-js Library to get all Items in SPFx

sp.web.lists.getByTitle("BigList").items.filter("YourFilter").getAll()

Or You can Try your API Like this

https://****.sharepoint.com/sites/test/_api/web/lists/getbytitle('ListData')/items?$filter=(ExpiryDate eq '2023-04-25T00:00:00.000Z') or (ExpiryDate eq '2023-05-11T00:00:00.000Z')
4
  • but i am using Power automate not pnp Apr 9, 2023 at 22:05
  • Check my updated answer Apr 10, 2023 at 5:16
  • thanks for the reply but how i can format my Date field as 2023-04-25T00:00:00.000Z .. also the expirtDate in my case is of type DateOnly (without time) Apr 10, 2023 at 10:26
  • You can just append the string "T00:00:00.000Z" in your date format Apr 10, 2023 at 23:06
0

Try using SharePoint REST API endpoint like this:

https://****.sharepoint.com/sites/test/_api/web/lists/getbytitle('ListData')/items?$filter=(ExpiryDate ge datetime'2023-04-25T00:00:00Z' and ExpiryDate le datetime'2023-04-25T23:59:00Z') or (ExpiryDate ge datetime'2023-05-11T00:00:00Z' and ExpiryDate le datetime'2023-05-11T23:59:00Z') or (ExpiryDate ge datetime'2023-06-07T00:00:00Z' and ExpiryDate le datetime'2023-06-07T23:59:00Z')

Similar thread: Power Automate Filter query on created date column

3
  • your call will raise this error "value: "String was not recognized as a valid DateTime."" Apr 11, 2023 at 18:10
  • Check updated answer. changed 000Z to 00Z and tested. It is working for me. Are you including datetime keyword in your filter query as mentioned in my answer? Apr 12, 2023 at 7:04
  • Is this working for you now? Apr 26, 2023 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.