cancel
Showing results for 
Search instead for 
Did you mean: 

date convertion YYYYMMDD to MM/DD/YYYY in sap ui5 table dynamic data coming from odata service

former_member338801
Participant
0 Kudos

Hi Experts,

I am getting date from the odata service. I have to convert YYYYMMDD format to MM/DD/YYYY format.

I am using formatter function to do so but it's not converting.

XML code:
<Text text="{path: 'key>date' ,formatter: '.formatter.dateConversion'}" id="__text8"/>

formatter code:
dateConversion: function (inputDate) {
    var date = new Date(inputDate);
    if (!isNaN(date.getTime())) {
     // Months use 0 index.
     return date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear();
    }

View Entire Topic
boghyon
Product and Topic Expert
Product and Topic Expert
  1. Make sure that the entity property has the type "Edm.DateTime" (in OData V2) or "Edm.Date" (in V4). Check the service $metadata document.
  2. In the app, bind the property with the data type "sap.ui.model.odata.type.DateTime" and the constraint "displayFormat: 'Date'". See How to Add Date / Time from OData Service Correctly to UI. For OData V4, the model automatically detects and sets the appropriate type to the binding. See topic Type Determination.