【问题标题】:How to filter DateTime data using sap.ui.model.Filter?如何使用 sap.ui.model.Filter 过滤 DateTime 数据?
【发布时间】:2017-01-19 07:34:21
【问题描述】:

我尝试使用 sap.ui.model.Filter 过滤 DateTime 数据:

oTableSearchState = [new Filter([ new Filter("Date", FilterOperator.Contains, sQuery), new Filter("Another_Date", FilterOperator.Contains, sQuery), ])]

它返回400 Bad String。我发现odata请求是...$filter substringof(,Date)。所以我知道使用“字符串过滤器”过滤日期是不正确的。

我需要的是...$filter= Date ge datetime'2016-08-17T16:00:00Z' and Date lt datetime'2016-08-18T16:00:00' 我可以用 sap.ui.model.Filter 做到这一点吗?或者唯一的方法是我自己将过滤器参数放在一起?

【问题讨论】:

标签: odata sapui5


【解决方案1】:

可以,请使用 sap.ui.model.Fitler 作为(使用运算符BT):

new sap.ui.model.Filter("Date", sap.ui.model.FilterOperator.BT, dateFrom, dateTo)

可以通过处理 sap.m.DateRangeSelection 事件“change”来选择日期

handleChange : function(oEvent){
        dateFrom = oEvent.getParameter("from");
        dateTo   = oEvent.getParameter("to");
}

【讨论】:

  • Filter Type="Edm.DateTimeOffset" 似乎不起作用,如何创建像 $filter=createdAt le datetimeoffset'2017-09-20T08:46:06.674Z' 这样的过滤器?我的结果是$filter=createdAt le Thu Jan 01 1970 08:00:10 GMT+0800 (CST)
猜你喜欢
  • 1970-01-01
  • 2019-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多