owlim-discussion  

Re: [Owlim-discussion] Can't filter dates!

Damyan Ognyanoff
Wed, 23 Jun 2010 23:56:11 -0700

Hi Adam,

comparing Calendar types is a bit tricky task - currently the xsd typecasts in 
the query engine do not convert the values to valid calendar values prior to 
apply the requested operation so you end up comparing incompatible calendar 
values which screw the whole query result - for your particular query the next 
one could do the job but it exploits the fact that all the dates related with 
the dbp:relesedate property have xsd:date datatype so promoting that type to 
the literal with which you compare will do the trick:

SELECT DISTINCT ?id ?relDate WHERE { 


?id rdf:type db-ont:Film  .  
?id db-ont:releaseDate ?relDate


FILTER(?relDate > ("2005-01-01"^^xsd:date))
}

n.b. you always could use str() operator instead to convert to a datatype-less 
values and compare them lexicographically e.g.
FILTER( str(?relDate) > "2005-01-01)


HTH,
Damyan Ognyanov
Ontotext AD
  ----- Original Message ----- 
  From: Adam Coen 
  To: owlim-discussion@ontotext.com 
  Sent: Wednesday, June 23, 2010 6:43 PM
  Subject: Re: [Owlim-discussion] Can't filter dates!


  Ok, that query was wrong, this is the right one:


  PREFIX fb-film: <http://rdf.freebase.com/ns/film.film.>PREFIX db-ont: 
<http://dbpedia.org/ontology/> PREFIX db-work: 
<http://dbpedia.org/ontology/Work/> PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: 
<http://www.w3.org/2002/07/owl#> PREFIX fb-alb: 
<http://rdf.freebase.com/ns/music.album.> PREFIX xsd: 
<http://www.w3.org/2001/XMLSchema#> 




  SELECT DISTINCT ?id ?relDate WHERE { 


  ?id rdf:type db-ont:Film  .  
  ?id db-ont:releaseDate ?relDate


  FILTER(xsd:dateTime(?relDate) > xsd:dateTime("2005-01-01"))
  }


  but it still gives me an empty result set...


  On 23 June 2010 16:52, Adam Coen <adamcoe...@googlemail.com> wrote:

    Hi
    I'd like to select each movie has been made from 2005 to today from 
dbpedia; so I write:


    PREFIX fb-film: <http://rdf.freebase.com/ns/film.film.>PREFIX db-ont: 
<http://dbpedia.org/ontology/> PREFIX db-work: 
<http://dbpedia.org/ontology/Work/> PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: 
<http://www.w3.org/2002/07/owl#> PREFIX fb-alb: 
<http://rdf.freebase.com/ns/music.album.> PREFIX xsd: 
<http://www.w3.org/2001/XMLSchema#> 




    SELECT DISTINCT ?id ?relDate WHERE { 


    ?id rdf:type db-ont:Film  .  
    ?id db-ont:releaseDate ?relDate


    FILTER(xsd:relDate(?dataUscita) > xsd:dateTime("2005-01-01"))
    }


    but unfortunately I don't get any results...this query looks right to 
me,isn't it? Why doesn't it work?




------------------------------------------------------------------------------


  _______________________________________________
  OWLIM-discussion mailing list
  OWLIM-discussion@ontotext.com
  http://ontotext.com/mailman/listinfo/owlim-discussion
_______________________________________________
OWLIM-discussion mailing list
OWLIM-discussion@ontotext.com
http://ontotext.com/mailman/listinfo/owlim-discussion