Search code examples
datetimefiltersparql

SPARQL Filter Date VALUES


I have created an RDF dataset in protege having dates of type "datetime" (I have not found option of creating simple dates)

I have the following query:

SELECT ?date
 WHERE {
   ?p ex:date ?date. 
   VALUES ?date {  2022-07-27T00:00:00  } 
} 

And I am getting the following error:

Undefined namespace prefix at 'T00' before ':00'

Is there a way to use VALUES to filter dates? I tried to use string as the type of the dates in protege' but I am still cannot filter dates using 'VALUES' in the SPARQL query.

Could you help me, please?


Solution

  • The problem solved after putting the literal in double quotes and also adding the datatype I needed as follows:

    SELECT ?date
     WHERE {
       ?p ex:date ?date. 
       VALUES ?date {   "2022-07-27"^^<w3.org/2001/XMLSchema#dateTime>  } 
    }