cancel
Showing results for 
Search instead for 
Did you mean: 

Date value is getting reduced by one day while passing it from UI5 application to Gateway system

Former Member

Hi Experts,

I have a UI5 application where i am passing a date value to a GET_ENTITYSET method of OData (V2) service. Data type of property is Edm.DateTime.

The problem is, in gateway system while debugging GET_ENTITYSET method, i observed that date value is getting reduced by one day. I suppose the problem is with timezone conversion because the UI5 client and gateway server are in different timezones.

Kindly help me with this problem.

Thanks,

Rahul

Accepted Solutions (1)

Accepted Solutions (1)

Hi Rahul,

you may set formatOptions:{UTC:true} when working with Time between frontend and backend, so that the Timezone will be calculated correctly by UI5.

Ex:

 {
  path: 'ChangeDateTime',
  type: 'sap.ui.model.type.DateTime',
  formatOptions: {UTC:true}
 }

I've just noticed that you're passing the date from the controller.
You can set the parameter UTC to true in the method "format".

I borrow the example above from Amit:

var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({
          pattern: "yyyy-MM-dd"
});
oDate = dateFormat.format(new Date(yourDate), true);

https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.core.format.DateFormat

Answers (3)

Answers (3)

amit5ingh
Participant

Hi Rahul,

There is some time zone issue while passing Date to backend, however you can use below trick to pass same date to backend.

var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({
          pattern: "yyyy-MM-dd"
});
oDate = dateFormat.format(new Date(yourDate));
oDate = oDate + "T00:00:00";

Regards,

Amit

Former Member
0 Kudos

Thanks Amit for your reply, will try this.

Former Member
0 Kudos

Amit, i tried with above manipulation of date, but it is still not working. I am passing the date as filter value to odata service.

amit5ingh
Participant
0 Kudos

Hi Rahul,

Strange it is not working for you,
can you please share your code snippet and request payload of network tab in debug mode.

Regrads,
Amit

Joseph_BERTHE
Active Contributor

The ui5 program send date in UTC +00H00 so in the back end system you should make the conversion when you parse the date with the statement

Convert date time....

Regards

former_member484715
Contributor
0 Kudos

You can also use the SY-DATUM in ABAP side. SY-DATUM gives the current date.

Former Member

We don't want current date, we want the same date which was passed from UI5 client application.