I am querying using SPARQL, which works fine. But when I add a data filter it doesn't throw an error but also it doesn't do the filter. The final part is that I should be able to query between two dates:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX hotel: <http://users.jyu.fi/~mimomuki/everything/hotel#>
SELECT *
WHERE { ?room hotel:hasCity ?sender; hotel:hasFirstDay ?Firstday
FILTER ( ?Firstday >= "2016-09-01"^^xsd:date )
}
SPARQL FILTER works as a positive filter. If the expression is true for any match, then the match stands. Otherwise the match is discarded and there won't be any bindings for ?room
?sender
and ?Firstday
. No error will be thrown as the query correctly returns no matches.
If you want to compare dates, you may want to ensure proper data type of operands in your filter expression. You can to that by casting both values to xsd:dateTime
FILTER ( xsd:dateTime(?Firstday) >= xsd:dateTime("2016-09-01") )
这个过滤器对我有用:
FILTER (?FirstDay>= "2016-09-01T00:00:00Z"^^xsd:dateTime)
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.