cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Odata date function

former_member208449
Active Participant
0 Likes
1,222

Hello experts,

As stated in the below article - SAP HANA Developer Guide for SAP HANA Studio - SAP Library

SAP HANA XS currently supports OData version 2.0, which you can use to send OData queries (for example, using the HTTP GET

method). Language encoding is restricted to UTF-8.


When is SAP HANA XS going to support Odata version 4.0(latest)? Odata 4.0 has support for a number of functions such as date(), time(), etc which aren't available with Odata 2.0.


Also since SAP HANA XS currently supports OData version 2.0, how should I compare a field whose data type in HANA is 'Date' by providing a value in the Odata URL ?


Eg -

http://hanaserver/my/user/services/getContract.xsodata/ContractBalance?$filter=VALID_FROM le ??&$format=json


Which value should be in the place of ?? in the above URL?

Tried using different date formats such as 2016-09-09 or /1451865600000/ etc. Nothing works.



Please help me out.

View Entire Topic
pfefferf
Active Contributor
0 Likes

Hello Gowthami,

an option would be to use the OData v2 supported functions "year", "month" and "day".

For the filter "<= 2016-09-09" the URL would look like following:


.../getContract.xsodata/ContractBalance?$format=json&$filter=year(VALID_FROM) lt 2016 or ( year(VALID_FROM) eq 2016 and month(VALID_FROM) lt 09) or ( year(VALID_FROM) eq 2016 and month(VALID_FROM) eq 09 and day(VALID_FROM) le 09 )

In words

  • get all data records which Valid From date year is lower than 2016
  • get all data records which Valid From date year is 2016 and month is lower than 09
  • get all data records which Valid From date year is 2016, which month is 09 and which day is lower or equal than 09

Regards,

Florian

former_member208449
Active Participant
0 Likes

Florian,

Yeah! I am aware of this method, But I wanted a way where I can give the date itself instead of comparing it against the components such as day, year & month.

Thank you.

pfefferf
Active Contributor
0 Likes

You can do it also in that way:

.../getContract.xsodata/ContractBalance?$format=json&$filter=VALID_FROM le datetime'20160909'


Regards,

Florian

former_member208449
Active Participant
0 Likes

Hello Florian

Yeah I wanted something like this! Thank you. Is there any documentation regarding the same?