User:MartinPoulter/queries/calendars

Calendar ordering of datesEdit

SELECT ?month_ordinal ?monthLabel ?day_ordinal WHERE {
?month wdt:P31 wd:Q47018901; wdt:P1545 ?month_ordinal.
?day p:P361 [ps:P361 ?month; pq:P1545 ?day_ordinal ]
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY xsd:integer(?month_ordinal) xsd:integer(?day_ordinal)

Try it!

Calendar of birthdays of women who studied at OxfordEdit

SELECT ?monthLabel (?day_int as ?d) ?personLabel ?personDesc
   (URI(CONCAT("https://tools.wmflabs.org/reasonator/?q=", SUBSTR(STR(?rperson),32) )) as ?link) WHERE {
{ SELECT ?month_int ?month ?day_int (SAMPLE(?person) AS ?rperson) WHERE {
?month wdt:P31 wd:Q47018901; wdt:P1545 ?month_ordinal. # These lines generate a calendar from January 1 to December 31
?day p:P361 [ps:P361 ?month; pq:P1545 ?day_ordinal ].
 BIND(xsd:integer(?month_ordinal) AS ?month_int)
 BIND(xsd:integer(?day_ordinal) AS ?day_int)
OPTIONAL {
# Define the people we're interested in
{?person wdt:P69 wd:Q34433 } UNION {?person wdt:P69/wdt:P31 wd:Q2581649 } # educated at Oxford or an Oxford college
?person wdt:P21 wd:Q6581072 ; # female
   p:P569/psv:P569 ?date_node. # birth date
?date_node wikibase:timePrecision "11"^^xsd:integer ; # birth date has specific day
   wikibase:timeValue ?birthdate .        
filter(DAY(?birthdate)=?day_int) filter (MONTH(?birthdate)=?month_int )
}
} GROUP BY ?month_int ?month ?day_int }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?rperson rdfs:label ?personLabel. ?rperson schema:description ?personDesc. ?month rdfs:label ?monthLabel }
} ORDER BY ?month_int ?day_int

Try it!

Calendar of birthdays of suffragistsEdit

SELECT ?monthLabel (?day_int as ?d) ?personLabel ?personDesc
   (URI(CONCAT("https://tools.wmflabs.org/reasonator/?q=", SUBSTR(STR(?rperson),32) )) as ?link) WHERE {
{ SELECT ?month_int ?month ?day_int (SAMPLE(?person) AS ?rperson) WHERE {
?month wdt:P31 wd:Q47018901; wdt:P1545 ?month_ordinal. # These lines generate a calendar from January 1 to December 31
?day p:P361 [ps:P361 ?month; pq:P1545 ?day_ordinal ].
 BIND(xsd:integer(?month_ordinal) AS ?month_int)
 BIND(xsd:integer(?day_ordinal) AS ?day_int)
OPTIONAL {
# Define the people we're interested in
{?person wdt:P106 wd:Q27532437 } UNION {?person wdt:P106 wd:Q322170 } # suffragette or suffragist
?person p:P569/psv:P569 ?date_node. # birth date
?date_node wikibase:timePrecision "11"^^xsd:integer ; # birth date has specific day
   wikibase:timeValue ?birthdate .        
filter(DAY(?birthdate)=?day_int) filter (MONTH(?birthdate)=?month_int )
}
} GROUP BY ?month_int ?month ?day_int }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?rperson rdfs:label ?personLabel. ?rperson schema:description ?personDesc. ?month rdfs:label ?monthLabel }
} ORDER BY ?month_int ?day_int

Try it!

Calendar of World __ daysEdit

Suggested by Andy Mabbett

SELECT DISTINCT ?month_int ?monthLabel (?day_int as ?d) ?world_dayLabel (?world_day as ?link) (GROUP_CONCAT(DISTINCT ?countryLabel; separator=", ") as ?countries) WHERE {
{ SELECT ?month_int ?month ?day_int ?world_day ?country WHERE {
?month wdt:P31 wd:Q47018901; wdt:P1545 ?month_ordinal.
?day p:P361 [ps:P361 ?month; pq:P1545 ?day_ordinal ].
 BIND(xsd:integer(?month_ordinal) AS ?month_int)
 BIND(xsd:integer(?day_ordinal) AS ?day_int)
VALUES ?type {wd:Q2558684 wd:Q422695} # World ___ day; Awareness day 
?world_day wdt:P31 ?type; wdt:P837 ?day
OPTIONAL {?world_day wdt:P17 ?country} 
}  }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
      ?month rdfs:label ?monthLabel. ?world_day rdfs:label ?world_dayLabel. ?country rdfs:label ?countryLabel }
} GROUP BY ?month_int ?monthLabel ?day_int ?world_dayLabel ?world_day
ORDER BY ?month_int ?d

Try it!

Calendar of saints' feast daysEdit

SELECT DISTINCT ?monthLabel (?day_int as ?d) ?saintLabel (URI(CONCAT("https://tools.wmflabs.org/reasonator/?q=", SUBSTR(STR(?saint),32) )) as ?link) WHERE {
{ SELECT ?month_int ?month ?day_int ?saint WHERE {
?month wdt:P31 wd:Q47018901; wdt:P1545 ?month_ordinal.
?day p:P361 [ps:P361 ?month; pq:P1545 ?day_ordinal ].
 BIND(xsd:integer(?month_ordinal) AS ?month_int)
 BIND(xsd:integer(?day_ordinal) AS ?day_int)
?saint wdt:P841 ?day # saint's feast day
}  }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?month_int ?d ?saintLabel

Try it!

Count of saint's feast days per dateEdit

#defaultView:BarChart
SELECT (CONCAT(STR(?monthLabel), " ", STR(?day_int)) AS ?calendar) (COUNT(?saint) AS ?count) ?month_int ?day_int WHERE {
{ SELECT ?month_int ?month ?day_int ?saint WHERE {
?month wdt:P31 wd:Q47018901; wdt:P1545 ?month_ordinal.
?day p:P361 [ps:P361 ?month; pq:P1545 ?day_ordinal ].
 BIND(xsd:integer(?month_ordinal) AS ?month_int)
 BIND(xsd:integer(?day_ordinal) AS ?day_int)
?saint wdt:P841 ?day # saint's feast day
}  }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?month rdfs:label ?monthLabel }
} GROUP BY ?month_int ?monthLabel ?day_int
ORDER BY ?month_int ?day_int

Try it!

Revised version of nuclear power plant construction queryEdit

The following query uses these:

  • Properties: instance of (P31)     , followed by (P156)     , point in time (P585)     , subclass of (P279)     , inception (P571)     , country (P17)     
     1 #defaultView:BarChart
     2 SELECT ?yearLabel (COUNT(?country) AS ?count) (SAMPLE(?cLabel) AS ?cLabel) WHERE {
     3   ?year wdt:P31 wd:Q577;
     4     wdt:P156/wdt:P585 ?next_year_point;
     5     wdt:P585 ?year_point.
     6   FILTER("1950-01-01"^^xsd:dateTime <= ?year_point && ?year_point < "2000-01-01"^^xsd:dateTime).
     7   OPTIONAL { ?object (wdt:P31/wdt:P279*) wd:Q134447.
     8   ?object wdt:P571 ?_inception.
     9   ?object wdt:P17 ?country.
    10   ?country rdfs:label ?countryLabel. FILTER((LANG(?countryLabel)) = "en")
    11   FILTER(?year_point <= ?_inception && ?_inception < ?next_year_point)
    12   }
    13   BIND(IF(BOUND(?country),?countryLabel,"none") AS ?cLabel)
    14   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    15 } GROUP BY ?yearLabel ?country
    16 ORDER BY ?yearLabel