query-e5dfadca112023bdaac2e1017ecb3a54

rq turtle/ttl

title:Personen mit Bezug zu Hannover, die heute ein Jubiläum haben

Abfrage von https://www.wikidata.org/wiki/User:Stefan_Kühn

---------------------------------------------------------------------------------------

SELECT DISTINCT ?item ?itemLabel ?firstnameLabel ?lastnameLabel ?itemDescription ?reason ?day WHERE { {?item wdt:P19 wd:Q1715} # Person mit Geburtsort = Hannover UNION {?item wdt:P20 wd:Q1715} # Person mit Todesort = Hannover UNION {?item wdt:P937 wd:Q1715} # Person mit Wirkungsort = Hannover

BIND( now() as ?testday) # Testdatum (heute) #BIND("2019-09-13T00:00:00Z"^^xsd:dateTime as ?testday) # Testdatum (beliebiger Tag)

{?item p:P569 [ a wikibase:BestRank ; # Geburtstag psv:P569 [ wikibase:timeValue ?day; wikibase:timePrecision ?precision_day ] ] FILTER (?precision_day > 8 ) # Geburtstag vollständig (YYYY-MM-DD) BIND( 'Geburtstag' as ?reason) } UNION {?item p:P570 [ a wikibase:BestRank ; # Todestag psv:P570 [ wikibase:timeValue ?day; wikibase:timePrecision ?precision_day ] ] FILTER (?precision_day > 8 ) # Todestag vollständig (YYYY-MM-DD) BIND( 'Todestag' as ?reason) }

FILTER (MONTH(?day) = MONTH(?testday)) # gleicher Monat FILTER (DAY(?day) = DAY(?testday)) # gleicher Tag

BIND (YEAR(?testday)-YEAR(?day) AS ?diffyear) # Jahresdifferenz errechnen BIND (FLOOR(?diffyear - (5 * FLOOR(?diffyear/5))) AS ?mod) # Modula 5
FILTER (?mod = 0) # nur Jahre wo Rest = 0 (5,10,15,20,25,...)

OPTIONAL { ?item wdt:P734 ?lastname . } # Nachname OPTIONAL { ?item wdt:P735 ?firstname . } # Vorname SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en,[AUTO_LANGUAGE]"} } ORDER BY DESC(?diffyear)

Use at

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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:Personen mit Bezug zu Hannover, die heute ein Jubiläum haben
#Abfrage von https://www.wikidata.org/wiki/User:Stefan_Kühn
#---------------------------------------------------------------------------------------
SELECT DISTINCT ?item ?itemLabel ?firstnameLabel ?lastnameLabel ?itemDescription ?reason ?day
WHERE 
{
  {?item wdt:P19 wd:Q1715} # Person mit Geburtsort = Hannover
  UNION
  {?item wdt:P20 wd:Q1715} # Person mit Todesort = Hannover
  UNION
  {?item wdt:P937 wd:Q1715} # Person mit Wirkungsort = Hannover

  BIND( now() as ?testday) # Testdatum (heute)
  #BIND("2019-09-13T00:00:00Z"^^xsd:dateTime as ?testday) # Testdatum (beliebiger Tag)

  {?item p:P569 [ a wikibase:BestRank ; # Geburtstag
                    psv:P569 [ wikibase:timeValue ?day;
                                                 wikibase:timePrecision ?precision_day ] ]
         FILTER (?precision_day > 8 ) # Geburtstag vollständig (YYYY-MM-DD)
         BIND( 'Geburtstag' as ?reason)
  }
  UNION
  {?item p:P570 [ a wikibase:BestRank ; # Todestag
                    psv:P570 [ wikibase:timeValue ?day;
                                                  wikibase:timePrecision ?precision_day ] ]
         FILTER (?precision_day > 8 ) # Todestag vollständig (YYYY-MM-DD)
         BIND( 'Todestag' as ?reason)
  }

  FILTER (MONTH(?day) = MONTH(?testday)) # gleicher Monat
  FILTER (DAY(?day) = DAY(?testday)) # gleicher Tag

  BIND (YEAR(?testday)-YEAR(?day) AS ?diffyear) # Jahresdifferenz errechnen 
  BIND (FLOOR(?diffyear - (5 * FLOOR(?diffyear/5))) AS ?mod) # Modula 5  
  FILTER (?mod = 0) # nur Jahre wo Rest = 0 (5,10,15,20,25,...)

  OPTIONAL { ?item wdt:P734 ?lastname . } # Nachname
  OPTIONAL { ?item wdt:P735 ?firstname . } # Vorname
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en,[AUTO_LANGUAGE]"}
} 
ORDER BY DESC(?diffyear)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?day"):::projected v8("?diffyear") v9("?firstname") v5("?item"):::projected v8("?lastname") v8("?mod") v6("?precision_day") v8("?reason"):::projected v6("?testday") a1((" ")) a2((" ")) a3((" ")) a4((" ")) c3(["wd:Q1715"]):::iri c8(["wikibase:BestRank"]):::iri c18(["bd:serviceParam"]):::iri c20(["de,en,#91;AUTO_LANGUAGE#93;"]):::literal f0[["?mod = '0^^xsd:integer'"]] f0 --> v8 f1[["day-from-dateTime(?day) = day-from-dateTime(?testday)"]] f1 --> v3 f1 --> v6 f2[["month-from-dateTime(?day) = month-from-dateTime(?testday)"]] f2 --> v3 f2 --> v6 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P937"--> c3 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P20"--> c3 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P19"--> c3 end union0r <== or ==> union0l end bind3[/"NOW()"/] bind3 --as--o v6 subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; f4[["?precision_day > '8^^xsd:integer'"]] f4 --> v6 a3 --"a"--> c8 a4 --"wikibase:timeValue"--> v3 a4 --"wikibase:timePrecision"--> v6 a3 --"p:statement/value/P570"--> a4 v5 --"p:P570"--> a3 bind5[/"'Todestag'"/] bind5 --as--o v8 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; f6[["?precision_day > '8^^xsd:integer'"]] f6 --> v6 a1 --"a"--> c8 a2 --"wikibase:timeValue"--> v3 a2 --"wikibase:timePrecision"--> v6 a1 --"p:statement/value/P569"--> a2 v5 --"p:P569"--> a1 bind7[/"'Geburtstag'"/] bind7 --as--o v8 end union2r <== or ==> union2l end bind8[/"year-from-dateTime(?testday) - year-from-dateTime(?day)"/] v6 --o bind8 v3 --o bind8 bind8 --as--o v8 bind9[/"numeric-floor(?diffyear - '5^^xsd:integer' * numeric-floor(?diffyear / '5^^xsd:integer'))"/] v8 --o bind9 bind9 --as--o v8 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P734".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P735".-> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c18 --"wikibase:language"--> c20 end