query-340da6eb3fa2014e6f9073345d67fc76
Propertiesinstance of (P31)subclass of (P279)point in time (P585)start time (P580)
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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#>
SELECT ?event ?eventLabel ?date
WHERE
{
# find events
?event wdt:P31/wdt:P279* wd:Q1190554.
# with a point in time or start date
OPTIONAL { ?event wdt:P585 ?date. }
OPTIONAL { ?event wdt:P580 ?date. }
# but at least one of those
FILTER(BOUND(?date) && DATATYPE(?date) = xsd:dateTime).
# not in the future, and not more than 31 days ago
BIND(NOW() - ?date AS ?distance).
FILTER(0 <= ?distance && ?distance < 31).
# and get a label as well
OPTIONAL {
?event rdfs:label ?eventLabel.
FILTER(LANG(?eventLabel) = "en").
}
}
# limit to 10 results so we don't timeout
LIMIT 10
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?date"):::projected
v5("?distance")
v4("?event"):::projected
v3("?eventLabel"):::projected
a1((" "))
c7(["wd:Q1190554"]):::iri
f0[["'0^^xsd:integer' <= ?distance?distance < '31^^xsd:integer'"]]
f0 --> v5
f1[["bound(?date)?date = 'xsd:dateTime'"]]
f1 --> v2
v4 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P585".-> v2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P580".-> v2
end
bind2[/"NOW() - ?date"/]
v2 --o bind2
bind2 --as--o v5
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."rdfs:label".-> v3
end