Consider this SPARQL where datetime is a date in 36 BC:
SELECT ?date ?year WHERE {
wd:Q1180731 wdt:P577 ?datetime .
BIND(xsd:date(?datetime) AS ?date)
# BIND(YEAR(?datetime) AS ?year)
}
The xsd:date(?datetime)
function fails on the Wikidata Query Service Blazegraph instance with java.lang.IllegalArgumentException: -036-01-01T00:00:00Z
.
Is it suppose to work? The line with YEAR
does not complain (when uncommented).
I have come up with this variation instead:
SELECT ?date WHERE {
wd:Q1180731 wdt:P577 ?datetime .
BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date)
}
In this case the result is -036-01-01
. The sortability of such BC dates may not be good. Do we have other methods/functions to make (string?) dates before year 1000 (including BC dates) sortable?