query-6d3f949c762bde896b0f61ed098e73a9
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?dob ?time_precision ?year ?month ?day ?ISO
WHERE
{
?item wdt:P31 wd:Q5 .
?item p:P569 ?p569stm1 .
?p569stm1 ps:P569 ?dob . # must have dob
?p569stm1 psv:P569 [wikibase:timePrecision ?time_precision] .
filter(?time_precision >8)
bind(year(?dob) as ?year)
bind(if(?time_precision >9,month(?dob),"00") as ?m)
bind(if(?time_precision >10,day(?dob),"00") as ?d)
bind(if(strlen(?m)=1,concat("0",str(?m)),?m) as ?month)
bind(if(strlen(?d)=1,concat("0",str(?d)),?d) as ?day)
bind(concat(str(?year),"-",str(?month),"-",str(?day)) as ?ISO)
# filter (?time_precision >10)
}
LIMIT 100
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?ISO"):::projected
v7("?d")
v9("?day"):::projected
v4("?dob"):::projected
v2("?item"):::projected
v6("?m")
v8("?month"):::projected
v3("?p569stm1")
v1("?time_precision"):::projected
v5("?year"):::projected
a1((" "))
c3(["wd:Q5"]):::iri
f0[["?time_precision > '8^^xsd:integer'"]]
f0 --> v1
v2 --"p:direct/P31"--> c3
v2 --"p:P569"--> v3
v3 --"p:statement/P569"--> v4
a1 --"wikibase:timePrecision"--> v1
v3 --"p:statement/value/P569"--> a1
bind1[/"year-from-dateTime(?dob)"/]
v4 --o bind1
bind1 --as--o v5
bind2[/"if(?time_precision > '9^^xsd:integer',month-from-dateTime(?dob),'00')"/]
v1 --o bind2
v4 --o bind2
bind2 --as--o v6
bind3[/"if(?time_precision > '10^^xsd:integer',day-from-dateTime(?dob),'00')"/]
v1 --o bind3
v4 --o bind3
bind3 --as--o v7
bind4[/"if(string-length(?m) = '1^^xsd:integer',concat('0',str(?m)),?m)"/]
v6 --o bind4
bind4 --as--o v8
bind5[/"if(string-length(?d) = '1^^xsd:integer',concat('0',str(?d)),?d)"/]
v7 --o bind5
bind5 --as--o v9
bind6[/"concat(str(?year),'-',str(?month),'-',str(?day))"/]
v5 --o bind6
v8 --o bind6
v9 --o bind6
bind6 --as--o v10