cancel
Showing results for 
Search instead for 
Did you mean: 

Date filter from SAPUI5 to oData

Former Member
0 Kudos

Hi everyone,

I'm trying to filter datetime oData results from a SAPUI5 application.

I'm doing it like:

var currentFormattedDate = "datetime'2015-29-04T00:00:00'";

var newFilter = new sap.ui.model.Filter("Date", sap.ui.model.FilterOperator.EQ, currentFormattedDate);

But doing it like this the request that SAPUI5 application is sending to oData is something like: Date%20eq%20datetime%270NaN-NaN-NaNTNaN%3aNaN%3aNaN%27

Is there any other way to do that filter works?

Thanks,

Marcel.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

currentFormattedDate should be Date not String

Former Member
0 Kudos

Now I'm creating currentFormattedDate with a function that returns string var created like:

return "datetime'" + yyyy + "-" + mm + "-" + dd + "T00:00:00'";

It can't be do it like this? In oData request by url must be this => "Date eq datetime'2015-04-29'" so I supposed that with a string should be possible.

former_member182372
Active Contributor
0 Kudos

Filter will take acare of the formating

lets say you use DateRage control

searchData.fromDate = dateRange.getDateValue();//javascipt Date

searchData.toDate  = dateRange.getSecondDateValue();//javascipt Date

new sap.ui.model.Filter({

   path: "DocumentDate",

   operator: sap.ui.model.FilterOperator.BT,

   value1: searchData.fromDate,

   value2: searchData.toDate
}));

will produce

  1. (DocumentDate ge datetime'2015-04-01T07:00:00' and DocumentDate le datetime'2015-05-02T07:00:00')
Former Member
0 Kudos

That's it!!! Now it works.

Many thanks,

Marcel.

Answers (0)