sparql如何根据日期范围进行过滤

sparql how to filter according to the date range

我有以下过滤器可以将我的数据过滤到 上周 的项目。

#just consider the likes in the last one week.
  filter (?ratingDate >= "2017-03-01T00:00:00"^^xsd:dateTime )

如你所见,我在手上设置了上周的日期时间(硬编码),有没有办法自动设置这个日期?

我正在寻找类似 now-7day

的内容

(合并评论)

现在 - 7 天 需要一些东西:

SPARQL 中有一个针对当前时间点的函数:now()

“7 天”是 xsd:duration、"P7D"^^xsd:duration

"-" 是涉及 xsd:dateTime 和 xsd:duration 的算术 -- 操作是 op:subtract-yearMonthDuration-from-dateTime(来自 "XPath and XQuery Functions and Operators")--并重载“-”操作以分派给该函数。

您需要检查您使用的 SPARQL 引擎是否支持 xsd:dateTime 的扩展和 xsd:duration 算法。

为 "now - 7 days" 计算出 xsd:dateTime 后,“>=”部分标准 SPARQL 的比较:

FILTER ( ?ratingDate >= (now()-"P7D"^^xsd:duration) )