query-7cfa7966099ba893b0716e2fccce4667
Born in January of a leap yearMe again. I'm looking for people born in January of a leap year. Two issues: value. What's going on here??itemLabel but that seems to break the ?year rdfs:label ?yearname .I'm fishing out the label for the leap year My (commented out) comparison of the Label for a leap year, with the year of birth, breaks things.
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?dob ?dobmonth ?dobyear ?strdobyear ?year ?yearname
WHERE
{
?item wdt:P31 wd:Q5. # human
?item wdt:P569 ?dob. # with a DoB
?item wdt:P106 wd:Q82955. # politician - cut down the result set size
?item wdt:P27 wd:Q145. #British - ditto
bind(year(?dob) as ?dobyear) # get the year
bind(month(?dob) as ?dobmonth) # get the month
filter(?dobmonth=1) # Only interested in January births
bind(str(?dobyear) as ?strdobyear) # just in case ?dobyear is an int
# ?year wdt:P31 wd:Q19828. # year is a leap year
# filter(?yearname=?strdobyear) #DoB year is a leap year
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?year rdfs:label ?yearname .
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?dob"):::projected
v5("?dobmonth"):::projected
v4("?dobyear"):::projected
v2("?item"):::projected
v5("?strdobyear"):::projected
v6("?year"):::projected
v7("?yearname"):::projected
c12(["en"]):::literal
c6(["wd:Q82955"]):::iri
c10(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
c8(["wd:Q145"]):::iri
f0[["?dobmonth = '1^^xsd:integer'"]]
f0 --> v5
v2 --"wdt:P31"--> c3
v2 --"wdt:P569"--> v3
v2 --"wdt:P106"--> c6
v2 --"wdt:P27"--> c8
bind1[/"year-from-dateTime(?dob)"/]
v3 --o bind1
bind1 --as--o v4
bind2[/"month-from-dateTime(?dob)"/]
v3 --o bind2
bind2 --as--o v5
bind3[/"str(?dobyear)"/]
v4 --o bind3
bind3 --as--o v5
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
v6 --"rdfs:label"--> v7
end