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

Sapui5 date one day missing

0 Likes
8,226

I want to show the date I got with DatePicker in a section in a table. But the date is missing 1 day.


I tried many methods:
https://answers.sap.com/questions/409976/sap-webide---ui5---date-field-is-not-showing-corre.html

https://answers.sap.com/questions/323063/date-value-is-getting-reduced-by-one-day-while-pas.html

But it didn't work. What is your suggestion?

View Entire Topic
Jagtar
Participant

I am assuming your table is directly binded to odata model

<Table items="{/ListSet}">

Can you confirm

if data save at backend for 5th date ?

if not then issue when you passing data to backend at time only you missing one day.

var vTarih = sap.ui.getCore().byId("dpKayitTarih").getDateValue();

To Solve this you need to do as below

resolveTimeDifference:function(dateTime){

if (dateTime !== undefined && dateTime !== null && dateTime !== "") {

var offSet = dateTime.getTimezoneOffset();

var offSetVal = dateTime.getTimezoneOffset() / 60;

var h = Math.floor(Math.abs(offSetVal));

var m = Math.floor((Math.abs(offSetVal) * 60) % 60);

dateTime = new Date(dateTime.setHours(h, m, 0, 0)); return dateTime;

}

return null;

},

var vTarih = this.resolveTimeDifference(sap.ui.getCore().byId("dpKayitTarih").getDateValue());

You are great. Thank you so much. Problem solved.

bugrayuksel130
Explorer
0 Likes

Thank you so much!