Posting date to SAP via OData using SAPUI5 Datepicker

Suppose that you have a datepicker sapui5 control and you want to pass the value of the datepicker to be posted to SAP using oData

<DatePicker id=”travelDate” />

var travelDate = this.byId('travelDate');
var dateVal = travelDate.getDateValue();

var dateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern : "yyyy-MM-ddTKK:mm:ss" });
var dateOdataVal = dateFormat.format(dateVal);

Then use the dateOdataVal in your oData values

Leave a Comment.