cancel
Showing results for 
Search instead for 
Did you mean: 

Defalut time is displaying for SmartTable in the date column

former_member213400
Active Participant
0 Kudos

Hello Experts and rohit.chokhani

I am facing the issue with default time for Date column in SmartTable. please find the below screenshot for same.

rohit.chokhani I found similar issue with you too, could you please share the solution/cod snippet so that I can try and check if the formatter works or not.

thank you in advance.

maheshpalavalli
Active Contributor
0 Kudos

Is it just a smart table or list report template based app?

Accepted Solutions (1)

Accepted Solutions (1)

former_member213400
Active Participant

Hi Mahesh,

Thank you for your valuable solution.

After adding the below piece of code still issue was there. When I double check the EDM Core Type in OData I found that column assigned as

Edm.DateTimeOffset. Since it is assigned I was getting default time in SmartTable date column, I changed EDM Core Type as Edm.DateTime.

METHODdefine.
  super->define().TRY.DATA(lo_entity_type)= model->get_entity_type( iv_entity_name ='Entity_Name').DATA(lo_property)= lo_entity_type->get_property( iv_property_name ='Date_Property_name').DATA(lo_annotation)= lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation('sap').
      lo_annotation->add( iv_key   ='display-format'
                          iv_value ='Date').CATCH/iwbep/cx_mgw_med_exception  .ENDTRY.ENDMETHOD.

But the catch is, when download as excel along with date default time 00.00 was coming. after adding above code those default 00.00 time is fixed. Once again Thank you soo much Mahesh for your time.

Regards, Kiran

Answers (1)

Answers (1)

0 Kudos

Hi Kiran,

You can use a formatter for the field.

Use the below code and you should be able to solve your problem -

<Text text="{path:'viewData>CreatedOn', type:'sap.ui.model.odata.type.DateTime', formatOptions: { pattern: 'MM-dd-yyyy'},constraints: {displayFormat: 'Date'}}"/>