-1

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 )      
        }
scotthenninger
  • 3,921
  • 1
  • 15
  • 24
Kinuthia
  • 61
  • 10
  • 1
    Are you sure the value of hotel:hasFirstday is an xsd:date and not simply a string literal in the same format? – chrisis Sep 13 '16 at 08:34

3 Answers3

0

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.

scotthenninger
  • 3,921
  • 1
  • 15
  • 24
0

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") )
Tomasz Pluskiewicz
  • 3,622
  • 1
  • 19
  • 42
0

This Filter worked for me:

FILTER (?FirstDay>= "2016-09-01T00:00:00Z"^^xsd:dateTime)
Yuri
  • 4,254
  • 1
  • 29
  • 46
Kinuthia
  • 61
  • 10