0

I am writing a query that calculates the age of someone knowing their birthdate and deathdate. I want to ask for a certain artist (in this case Michael Jackson). The problem is that I can't reuse the birthdate and deathdate in the following query:

select ?artist ?age  
where { 
  dbr:Michael_Jackson dbo:birthDate ?birthdate .

  dbr:Michael_Jackson dbo:deathDate ?deathdate . 

  bind( year(?deathdate) - year(?birthdate) - if(month(?deathdate)<month(?birthdate) || (month(?deathdate)=month(?birthdate) && day(?deathdate<day(?birthdate)),1,0) as ?age)
}

Anyone knows how to solve this problem?

TallTed
  • 9,069
  • 2
  • 22
  • 37
Diew
  • 3
  • 3
  • 1
    the error is `Virtuoso 22003 Error SR586: Incomplete RDF box as argument 0 for year().` - I guess this happens because of a wrong lexical form of the date literal – UninformedUser Oct 25 '18 at 12:34
  • You said you "can't reuse the birthdate and deathdate." Why not? Please post any error message you're getting, as I see something different than @AKSW. – TallTed Oct 25 '18 at 13:40
  • @TallTed the query in the question fails because of some syntax errors, but the correct query fails because of the error I've shown in my comment above: `select ?artist ?age where { values ?artist {dbr:Michael_Jackson} ?artist dbo:birthDate ?birthdate . ?artist dbo:deathDate ?deathdate . bind( year(?deathdate) - year(?birthdate) - if(month(?deathdate) – UninformedUser Oct 25 '18 at 16:36

1 Answers1

0

I edited the query a bit to get the values you're calculating against --

birthdate                                              deathdate
"1958-8-29"^^<http://www.w3.org/2001/XMLSchema#date>   "2009-6-25"^^<http://www.w3.org/2001/XMLSchema#date>

The error you're hitting is because these are not valid xsd:date literals -- which require 2 digits for the month.

This data issue has been fixed on Wikipedia and so on DBpedia-Live, and your query works there, as you can see. There are other issues with DBpedia-Live data (such as multiple versions of the abstract being shown, when you really only want to see the latest), but perhaps this solves your immediate need.

TallTed
  • 9,069
  • 2
  • 22
  • 37