I want to use filter with date , the filter should be somthing like that :
/MyEntitySet?$filter=Erdat gt datetime'2018-02-04T00:00:00' and Erdat lt
datetime'2018-02-04T00:00:00
But I don't get that while using this in sapui5 :
var date = this.byId("date1").getDateValue();
var date2 = this.byId("date2").getValue();
var oDateFormat = sap.ui.core.format.DateFormat.getInstance({
pattern: "yyyy-MM-ddTHH:mm:ss"
});
var oDate = oDateFormat.format(oDateFormat.parse(date));
var oDateFormat2 = sap.ui.core.format.DateFormat.getInstance({
pattern: 'yyyy-MM-ddTHH:MM:SS'
});
var oDate2 = oDateFormat.format(oDateFormat.parse(date2));
Anyone have an idea about that please , I will be grateful. Thank you
You don't need to format the data by yourself, just build the Filter and apply to the odata request directly.
sap.ui.define(['sap/ui/model/Filter', 'sap/ui/model/FilterOperator'],
function(Filter, FilterOperator) {
new Filter({
path: "Erdat",
operator: FilterOperator.BT,
value1: date,
value2: date2
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.