Wimmics/corese

[Request] substraction of two dates (typed with xsd) returns a xsd:duration

MaillPierre opened this issue · 0 comments

Is your feature request related to a problem? Please describe.
As part of my project, I store the start and end times of query execution in a dataset. As a post-treatment, I would like to be able to compute the duration of each query execution and add this information to the dataset using a SPARQL query.

Currently, the following query returns no result:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?duree (DATATYPE(?duree) AS ?dt) WHERE { 
  BIND(("2023-09-12T15:19:41.963Z"^^xsd:datetime - "2023-09-12T14:19:41.963Z"^^xsd:datetime) AS ?duree)
}

Describe the solution you'd like
Ideally, I would like the previous query to return something such as:

duree dt
"PT1H"^^xsd:duration xsd:duration

It would work for operations between literals of the same type such as date, datetime, time, gYear, etc.
Operations between literals of different types maybe more complex to implement.

Describe alternatives you've considered
The alternative right now is to decompose each datetime to its component (day, hours, minutes, etc.) and do arithmetic operations on them, or do the computation outside the query.

Additional context
Tested on Corese server corese-server-4.4.1.jar