query-ab7313cbf30aef6d4c8cd586e572c41c
And more specifically, with leading zeros. This is as close as I've got yet:
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?wikidata_groupLabel ?genderLabel ?areaLabel (CONCAT(STR(YEAR(?DoB)),
"-",
STR(MONTH(?DoB)),
"-",
STR(DAY(?DoB))) as ?displayDate)
WHERE {
?item p:P39 ?mem.
?mem ps:P39 wd:Q18607856.
OPTIONAL { ?mem pq:P4100|pq:P102 ?wikidata_group. }
OPTIONAL { ?mem pq:P768 ?area. }
OPTIONAL { ?item wdt:P21 ?gender. }
OPTIONAL { ?item wdt:P569 ?DoB. }
FILTER NOT EXISTS { ?mem pq:P582 []. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?DoB"):::projected
v4("?area")
v7("?displayDate")
v5("?gender")
v2("?item"):::projected
v1("?mem")
v3("?wikidata_group")
a1((" "))
c11(["bd:serviceParam"]):::iri
c4(["wd:Q18607856"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"p:qualifier/P582"--> e0a1
e0v1("?mem"):::projected
e0a1((" ")):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> c1
f0 --> a1
v1 --"p:qualifier/P582"--> a1
v2 --"p:P39"--> v1
v1 --"p:statement/P39"--> c4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 -."p:qualifier/P102".-> v3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:qualifier/P4100"--> v3
end
union0r <== or ==> union0l
end
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:qualifier/P768".-> v4
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P21".-> v5
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P569".-> v6
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end
bind1[/"concat(str(year-from-dateTime(?DoB)),'-',str(month-from-dateTime(?DoB)),'-',str(day-from-dateTime(?DoB)))"/]
v6 --o bind1
bind1 --as--o v7