SPARQL Calculating the difference between two date -


what function calculate difference between 2 sparql xsd:datetime ?

i have found reference datediff, not working. such built in function exist in sparql other query languages?

some sparql engines may support date arithmetic directly. instance, mention in this answers.semanticweb.com question , answer, jena supports date arithmetic, , can subtract 1 date , xsd:duration. other implementations may support datediff function. instance, this virtuoso example includes use of bif:datediff. however, these extensions , not guaranteed present in particular sparql implementation.

for more portable, though possibly less efficient solution, can use year extract year parts datetime. lets do, instance,

select ?age {    bind( "1799-12-14"^^<http://www.w3.org/2001/xmlschema#date> ?death )   bind( "1732-02-22"^^<http://www.w3.org/2001/xmlschema#date> ?birth )   bind( year(?death)-year(?birth) ?age ) } 

and results

------- | age | ======= | 67  | ------- 

this has potential off one, depending on months , days of 2 dates, can work around using month , day functions. this thread describes of sort of implementation.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -