[英]Date filter using sapui5
我想使用帶日期的過濾器,過濾器應該像這樣:
/MyEntitySet?$filter=Erdat gt datetime'2018-02-04T00:00:00' and Erdat lt
datetime'2018-02-04T00:00:00
但是在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));
任何人對此都有一個想法,我將不勝感激。 謝謝
您不需要自己格式化數據,只需構建過濾器並直接應用於odata請求即可。
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
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.