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?