on 03-11-2014 9:11 AM
Hello,
I am trying to use the OData Filter query. to filter data records from the OData Service, using Date range for filters.
Please check the below URL for the SAP's sample OData Service, with filter option.
Service Query URL :
https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV/SalesOrderCollection?$filter=Created... eq DateTime
It gives out following error 😆
<message xml:lang="en">'$filter ' is not a valid system query option</message>
Please let me know, if there is any mistake in the Query or is there anything that needs to be done on the
Backend Service.
Thanks & Regards,
Suraj Kumar
Hi Suraj,
As you mentioned in your query, URL
https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV/SalesOrderCollection?$filter=Created... eq DateTime
I believe filter should be like
$filter=OrderDate eq datetime'2014-03-11T14:49:52'
Please check once.
Rgrds,
Jitendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jitendra,
Thank you for your prompt reply.
By adding " ? " to your suggestion i.e. " $filter=OrderDate eq datetime'2014-03-11T14:49:52' ", I was able to get the result.
All this while, I was trying with "DateTime" instead of "datetime".
Had it not been to your reply, I wouldn't have got the solution.
I have got another issue. I tried to find records between a given date range say 2013-12-03T00:00:00 and 2013-12-24T00:00:00.
I tried using "and" with "ge" and "le" parameters, but I am not getting any result.
Could you please help me with this?
Thank you for your earlier solution.
Thanks & Regards,
Suraj Kumar.
Glad to know you are able to get the details.
I have got another issue. I tried to find records between a given date range say 2013-12-03T00:00:00 and 2013-12-24T00:00:00.
I tried using "and" with "ge" and "le" parameters, but I am not getting any result.
I never tried this but you can check
is this how you tried?
$filter=OrderDate ge datetime'2014-03-10T12:01:03' and OrderDate le datetime'2014-03-11T13:01:02'
Rgrds,
Jitendra
Hi Jitendra,
Once again, thank you for your help.
I am able to filter the records using a date range.
I am sharing the information, just in case anyone out there might need it.
The OData Filter Query for Date Range (i.e. with Two date values) will return the results only if the OData Back-end Service is modified to accommodate such filter requests.
This has to be done in ABAP.
Please refer the following links which talks more about the Back-end ABAP Service being modified to ensure that the service returns records of data, as per the date range filter query
http://scn.sap.com/thread/3170195
http://scn.sap.com/thread/3173146
Hope these links are helpful for those looking for OData Date Range filter query.
Do let me know.
Regards,
Suraj Kumar.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.