问题
I get the following error.
Virtuoso 22007 Error DT006: Cannot convert -0359 to datetime : Incorrect month field length
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1 select ?item bif:year(xsd:dateTime( str(?dob))) as ?m{
?item <h://f.cm/ns/common/topic/notable_types> <h://f.cm/ns/people/person> .
?item <h://f.cm/ns/people/person/date_of_birth> ?dob
} limit 675
If I change the limit to 674
, it works.
What I suspected was that some datetime field is wrong somewhere and printed ?dob
, which revealed that one of the values is -0359
.
Solution is to validate the value before applying bif
function.
But, how can we validate datetime in SPARQL?
回答1:
Well, I found this question via Google because I had the same problem. Looking elsewhere for help, I found the following solution:
SELECT * {
?s ?p ?o
FILTER ( datatype(?o) = xsd:datetime )
FILTER ( coalesce(xsd:datetime(str(?o)), '!') != '!')
}
This worked for me.
Note that I found the answer to this at SemanticWeb.
来源:https://stackoverflow.com/questions/13896118/how-to-validate-datetime-object-in-sparql-virtuoso-22007-error-dt006