for:

BIND(?date_of_death - ?date_of_birth as ?duration)

?duration is

"P25045DT0H0M0.000S"^^<http://www.w3.org/2001/XMLSchema#duration>

Is it possible to extract days/years value from it in Sparql?



2013/12/6 Andy Seaborne <[email protected]>

> On 06/12/13 12:16, Ewa Szwed wrote:
>
>> Hello,
>>
>> I would like to ask if it is doable to do something like this in Sparql on
>> Jena TDB.
>>
>> I would like to calculate the difference between 2 dates.
>>
>> What I have at the moment working is:
>>
>>      BIND(fn:year-from-dateTime(?date_of_birth) AS ?year_of_birth)
>>
>
> shorter:
> YEAR(?date_of_birth)
>
>
>       BIND(fn:year-from-dateTime(?date_of_death) AS ?year_of_death)
>>      BIND(?year_of_death - ?year_of_birth AS ?age)
>>      BIND(fn:concat(?age, " (", ?year_of_birth, "-", ?year_of_death,
>> ")" ) AS ?age_at_death)
>>
>
> ARQ supports xsd:duration.
>
> ?date_of_death - ?date_of_birth -> xsd:duration
>
> assuming ?date_of_death and ?date_of_birth are well-formed xsd:dateTimes.
>
>
>
>> Unfortunately it is not perfect calculation because it just subtracts two
>> years from ech other and will now answer precisely how old was someone
>> when
>> he died.
>>
>> I would need to extract years from xsd:duration
>>
>> Is it possible to do it?
>>
>> I would appreciate any answer.
>>
>>
>

Reply via email to