cancel
Showing results for 
Search instead for 
Did you mean: 

Sapui5 one before day problem

former_member489109
Participant
0 Kudos

var sToday = new Date(); //today// example : 20.12.2017

this.getView().byId("mesaiTbdPicker").setDateValue(sToday); // set today to datepicker //20.12.2017

and I sending this data.But i looking data in abap date looking 1 before day. //19.12.2017

I tried this but not worked;

var sToday = new Date();

sToday = sToday + 1;

Please help.

Accepted Solutions (1)

Accepted Solutions (1)

Joseph_BERTHE
Active Contributor
0 Kudos

You have to play with the timezone such as CET to get the correct date.

Answers (3)

Answers (3)

junwu
Active Contributor
0 Kudos

it may not be a problem, the browser is showing local time, the abap side is showing server time,

iftah_peretz
Active Contributor
0 Kudos

Hi,

In addition to handling it on the front-end (to add on the point already made), you can add a day on the back-end ABAP side.

former_member489109
Participant
0 Kudos
I used abap code it elsewhere.So I can not change it there.But the problem is solved by itself.I didntunderstand. 2-3 hour after i checked code problem solved.

Thanks for answer.



irfan_gokak
Contributor
0 Kudos

Hi,

Before sending date value to the oData you have to format it in format as "YYYY-MM-DDTHH:MM:SS". Use below formatter to do this. Passing date object to the odata cause this issue.

// format date for create
dateFormat:function(value) {
	if(value == null){
		return null;
	}
    	var _smonth = value.getMonth() + 1;
	var _sdate = value.getDate();
	if (_smonth.toString().length < 2) {
		_smonth = "0" + _smonth.toString();
	}
	if (_sdate.toString().length < 2) {
		_sdate = "0" + _sdate.toString();
	}
    	var	formatDate = value.getFullYear()	+ '-' + _smonth + '-' + _sdate + "T00:00:00";
	return formatDate;
},
former_member489109
Participant
0 Kudos

Hi Irfan,

I tryed your code but not worked. Check this. (this.dateFormat your format style.) // 21.12.2017 true value

Chek here. One before day. // 20.12.2017 false code.

please help.

irfan_gokak
Contributor
0 Kudos

Try this

var sPath = "/MainSet?$filter=Pernr eq '"+this.pernr+"' and 'Tarih eq datetime'"+dDate+"'";
// After this make odata call