cancel
Showing results for 
Search instead for 
Did you mean: 

Filter using Time Field

Former Member
2,556

Hi All,

I want to know how to pass time field Edm.Time value in filter parameter. I check https://archive.sap.com/discussions/thread/3558834 post and it guided me to pass $filter=(DepDate EQ datetime'2013-01-02T00:00:00') for Date fields and it works. In case of time field, when I pass DepTime EQ 'PT11H00M00S' it didnt work. I checked "Working with OData Dates and Times" Blog by John Patterson for formatting "DepartureTime": "PT11H00M00S" Time field value into 11:00 AM for displaying value in UI5. I want to know what format time value needs to be send in filter parameter and also in /IWFND/GW_CLIENT testing. Many thanks,

Raj

Accepted Solutions (0)

Answers (3)

Answers (3)

Ankit_Maskara
Product and Topic Expert
Product and Topic Expert
0 Kudos

Referring from the OData V2 specification it should be 'Represents the time of day with values ranging from 0:00:00.x to 23:59:59.y, where x and y depend upon the precision' with example -

Example 1: PT13H20M

In your case try without single quotes.

http://www.odata.org/documentation/odata-version-2-0/overview/

adrian_muntean
Explorer
0 Kudos

ankit.maskara3 I have the sam issue. I have a Edm.Time field (CreatedAt from the BusinessPartner SAP API Business Hub) and I am trying to filter based on that field. I've tried

$filter=CreationTime eq PT13H20M
$filter=$filter=CreationTime eq 'PT13H20M'

and it returns an error 'Invalid parametertype used at function eq'. Any ideas on why this is not working?

Ankit_Maskara
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Adrian,

For passing date time in filters, please refer an example from how My Inbox app does it i.e. -

$filter=<property_name> ge datetime '2022-09-05T22:00:00'

Best Regards.

CristianBabei
Contributor
0 Kudos

This works:

https://archive.sap.com/discussions/thread/3965066

If it dosn't for you, then, let us see your EntitySet - property declaration, and how you send the data to backend.

lmanriquez
Explorer
0 Kudos

Maybe it's too late but I managed to work with an ODATA V2 like this:

$filter=CreationTime eq time'PT11H00M00S'