Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SPARQL date conversion

We have created a SPARQL endpoint using dotnetrdf and I am a beginner when related to SPARQL. The date fields have been stored as strings in the format MM/DD/YYYY. Now, there is requirement for date comparison (> <) for which the string will have to be converted to xsd:datetime or xsd:date in the SPARQL query. Is there a way to do this? Any other alternative?

Are there any good examples available for date related SPARQL queries in dotnetrdf?

Thanks.

like image 982
Sandhya Avatar asked Jun 21 '12 09:06

Sandhya


1 Answers

I think the answer is that you can, but probably don't want to!

You should be able to do it with the SPARQL 1.1 SUBSTR function, along with concat and strdt.

Something along the lines of

strdt(concat(substr(?x, 7, 4), '-', substr(?x, 1, 2), '-', substr(?x, 4, 2), 'T00:00:00'), xsd:dateTime)

Where ?x is bound to your MM/DD/YYYY date value. The return value of that function should be a legal xsd:dateTime, assuming no typos.

If it were me, I'd extract all the MM/DD/YYYY data, process it externally, and add additional data as xsd:dates or xsd:dateTimes.

like image 125
Steve Harris Avatar answered Sep 28 '22 08:09

Steve Harris