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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With