cancel
Showing results for 
Search instead for 
Did you mean: 

DatePicker - Wrong conversion in the date range - ToDate is increased by 1 day always

former_member184739
Contributor
3,528

Hello Experts,

I'm experiencing a weird scenario where the date range in the UI5 datepicker is not picking up the correct values. Let me summarize the steps done and what exactly the issue am facing.

I have placed the datepicker range as per the following code in the view.xml file.

<DateRangeSelection id="dateCreatedOn" placeholder="{i18n>enterCreatedOn} ..." valueFormat="MM-dd-yyyy" displayFormat="MM.dd.yyyy"/>

Date range selected in the user screen is captured in the controller.js as shown below.

if (dateCreatedOnFrom && dateCreatedOnTo) {
  dateCreatedOnFrom = new Date(dateCreatedOnFrom);
  dateCreatedOnTo = new Date(dateCreatedOnTo);
 this.inputFilters.push(new Filter("CreatedOn", FilterOperator.BT, dateCreatedOnFrom, dateCreatedOnTo));
			}

As you can notice when debugging this in Chrome, date range values i.e., both from and to are fine.

Date ranges selected in the UI5 application:

Values in Google Chrome console:

But when the odata call is triggered to SAP Gateway 'dateCreatedOnTo' value is changed i.e., increased by 1 day when the odata call is triggered.

/SearchResultSet?sap-client=110&$filter=CreatedBy eq 'SUZIP' and (CreatedOn ge datetime'2020-09-21T04:00:00' and CreatedOn le datetime'2020-09-25T03:59:59.999')

When call reached the backend i.e., ECC, we can notice the changed date values which leads to pull wrong data.

Note:

SAPUI5 version: 1.71.4 is deployed in the Gateway FrontEnd server.

Please shed some lights on this issue. Thank you for the support.

Regards

Praba

View Entire Topic
former_member184739
Contributor
0 Kudos

Thanks a lot folks. I now understood what the problem is. Much appreciated.