cancel
Showing results for 
Search instead for 
Did you mean: 

date conversions in OData

0 Kudos

Hello experts,

i am trying to create a entityset in OData which contains some date fields, but getting conversion errors, because edm.datetime is having length 7.

request your help.

thanks.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

We were facing similar issue.What we did was changed code in DEFINE method of model provider ext class like below.

lo_property = lo_entity_type->create_property( iv_property_name = 'DATEFIELDNAME' iv_abap_fieldname = 'DATEFIELDNAME' ). "#EC NOTEXT

*lo_property->set_label_from_text_element( iv_text_element_symbol = '100' iv_text_element_container = gc_incl_name ).       "#EC NOTEXT

lo_property->SET_TYPE_EDM_DATETIME( ).

lo_property->set_maxlength( iv_max_length = 8 ).

lo_property->set_creatable( abap_false ).

lo_property->set_updatable( abap_false ).

lo_property->set_internal_type( 'P' ).

lo_property->set_internal_length( 8 ).

lo_property->set_sortable( abap_false ).

lo_property->set_nullable( abap_false ).

lo_property->set_filterable( abap_false ).


Hope this helps

Regards

vijay_kumar49
Active Contributor
0 Kudos

OData Dates and Times

try with this code

jQuery.sap.require("sap.ui.model.odata.ODataUtils");

var sPath = "/MyEntitiySet(Id='0815', ChDateTime=" + ODataUtils.formatValue(1436109229000, "Edm.DateTime") + ")";

  1. jQuery.sap.require("sap.ui.model.odata.ODataUtils"); 
  2. var sPath = "/MyEntitiySet(Id='0815', ChDateTime=" + encodeURIComponent(sap.ui.model.odata.ODataUtils.formatValue(1436109229000, "Edm.DateTime")) + ")"
Private_Member_15166
Active Contributor
0 Kudos

Perhaps use TIMESTAMPL as data element and do Date formatting at SAPUI5 App.

TIMESTAMPL is actually UTC Time Stamp in Long Form (YYYYMMDDhhmmssmmmuuun).