query-a4c67fd30272a0b2b721d30a1013d106
NanarBoulier
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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 ?born ?position ?positionLabel ?position_start ?ageInDays ?years ?months ?days
WHERE
{
?item p:P39 ?position_stm.
?position_stm ps:P39 ?position.
?position wdt:P279* wd:Q18384454.
?position_stm pq:P580 ?position_start.
?item wdt:P569 ?born.
BIND (?position_start - ?born AS ?ageInDays)
BIND (YEAR(?born) AS ?Y1)
BIND (YEAR(?position_start) AS ?Y2)
BIND (MONTH(?born) AS ?M1)
BIND (MONTH(?position_start) AS ?M2)
BIND (DAY(?born) AS ?D1)
BIND (DAY(?position_start) AS ?D2)
BIND (?Y2 - ?Y1 - IF(?M1 > ?M2 || (?M2 = ?M1 && ?D1 > ?D2), 1, 0) AS ?years)
BIND (IF(?M2 > ?M1 || (?M2 = ?M1 && ?D2 >= ?D1), ?M2 - ?M1, 12 + ?M2 - ?M1) - IF(?D2 < ?D1, 1, 0) AS ?months)
BIND (IF(?D2 >= ?D1, ?D2 - ?D1, xsd:integer(?position_start - (?position_start - "P1M"^^xsd:duration)) + ?D2 - ?D1) as ?days)
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;
v11("?D1")
v12("?D2")
v9("?M1")
v10("?M2")
v7("?Y1")
v8("?Y2")
v6("?ageInDays"):::projected
v5("?born"):::projected
v15("?days"):::projected
v1("?item"):::projected
v14("?months"):::projected
v3("?position"):::projected
v4("?position_start"):::projected
v2("?position_stm")
v13("?years"):::projected
c8(["bd:serviceParam"]):::iri
c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c4(["wd:Q18384454"]):::iri
v1 --"p:P39"--> v2
v2 --"p:statement/P39"--> v3
v3 --"p:direct/P279"--> c4
v2 --"p:qualifier/P580"--> v4
v1 --"p:direct/P569"--> v5
bind0[/"?position_start - ?born"/]
v4 --o bind0
v5 --o bind0
bind0 --as--o v6
bind1[/"year-from-dateTime(?born)"/]
v5 --o bind1
bind1 --as--o v7
bind2[/"year-from-dateTime(?position_start)"/]
v4 --o bind2
bind2 --as--o v8
bind3[/"month-from-dateTime(?born)"/]
v5 --o bind3
bind3 --as--o v9
bind4[/"month-from-dateTime(?position_start)"/]
v4 --o bind4
bind4 --as--o v10
bind5[/"day-from-dateTime(?born)"/]
v5 --o bind5
bind5 --as--o v11
bind6[/"day-from-dateTime(?position_start)"/]
v4 --o bind6
bind6 --as--o v12
bind7[/"?Y2 - ?Y1 - if((?M1 > ?M2 || ?M2 = ?M1?D1 > ?D2),'1^^xsd:integer','0^^xsd:integer')"/]
v8 --o bind7
v7 --o bind7
v9 --o bind7
v10 --o bind7
v11 --o bind7
v12 --o bind7
bind7 --as--o v13
bind8[/"if((?M2 > ?M1 || ?M2 = ?M1?D2 >= ?D1),?M2 - ?M1,'12^^xsd:integer' + ?M2 - ?M1) - if(?D2 < ?D1,'1^^xsd:integer','0^^xsd:integer')"/]
v10 --o bind8
v9 --o bind8
v12 --o bind8
v11 --o bind8
bind8 --as--o v14
bind9[/"if(?D2 >= ?D1,?D2 - ?D1,http://www.w3.org/2001/XMLSchema#integer(?position_start - ?position_start - 'P1M^^xsd:duration') + ?D2 - ?D1)"/]
v12 --o bind9
v11 --o bind9
v4 --o bind9
bind9 --as--o v15
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end