我在jena fuseki rdf商店有很多图形名称, 这些是我的图表的名称:
| <http://stormsmacs/tests/2015-03-03T04:27:57Z> |
| <http://stormsmacs/tests/2015-03-03T05:20:59Z> |
| <http://stormsmacs/tests/2015-03-03T05:22:29Z> |
| <http://stormsmacs/tests/2015-03-03T05:25:03Z> |
| <http://stormsmacs/tests/2015-03-03T05:27:01Z> |
| <http://stormsmacs/tests/2015-03-03T05:30:37Z> |
| <http://stormsmacs/tests/2015-03-03T05:44:02Z> |
| <http://stormsmacs/tests/2015-03-03T05:52:19Z> |
| <http://stormsmacs/tests/2015-03-03T05:58:47Z> |
等等。 如何过滤图形以获得两个日期之间的所有图形?
非常感谢你!答案 0 :(得分:2)
当我们使用实际数据时,它会更容易。请务必提供我们将来可以使用的数据。对于这种情况,我只是使用值块将带有嵌入日期时间的URI绑定到?dateUri 变量。查询中的注释解释了发生了什么。一般的想法是将URI转换为字符串,去掉公共前缀,将后缀转换为 xsd:dateTime ,以及基于它的过滤器。
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select ?dateTime where {
#-- the "dates" encoded in URIs
values ?dateUri { <http://stormsmacs/tests/2015-03-03T04:27:57Z>
<http://stormsmacs/tests/2015-03-03T05:20:59Z>
<http://stormsmacs/tests/2015-03-03T05:22:29Z>
<http://stormsmacs/tests/2015-03-03T05:25:03Z>
<http://stormsmacs/tests/2015-03-03T05:27:01Z>
<http://stormsmacs/tests/2015-03-03T05:30:37Z>
<http://stormsmacs/tests/2015-03-03T05:44:02Z>
<http://stormsmacs/tests/2015-03-03T05:52:19Z>
<http://stormsmacs/tests/2015-03-03T05:58:47Z> }
#-- an arbitrary begin and end date
values ?begin { "2015-03-03T05:22:29Z"^^xsd:dateTime }
values ?end { "2015-03-03T05:44:02Z"^^xsd:dateTime }
#-- extract the dateTime portion from the URI string, and convert
#-- it to an xsd:dateTime.
bind( xsd:dateTime(strafter(str(?dateUri),"http://stormsmacs/tests/")) as ?dateTime )
#-- filter results based on the begin and end time
filter( ?begin <= ?dateTime && ?dateTime <= ?end )
}
----------------------------------------
| dateTime |
========================================
| "2015-03-03T05:22:29Z"^^xsd:dateTime |
| "2015-03-03T05:25:03Z"^^xsd:dateTime |
| "2015-03-03T05:27:01Z"^^xsd:dateTime |
| "2015-03-03T05:30:37Z"^^xsd:dateTime |
| "2015-03-03T05:44:02Z"^^xsd:dateTime |
----------------------------------------