relizt
relizt

Reputation: 375

Wikidata SPARQL query that returns date a particular property was last edited on queried items

Let's say I'm looking for Wikidata cats who have their place of birth (P19) listed, using this query (also at https://w.wiki/5mdp):

SELECT ?item ?itemLabel ?placeofbirthLabel ?date
WHERE 
{
  ?item wdt:P31 wd:Q146;
        wdt:P19 ?placeofbirth;
        schema:dateModified ?date.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

This retrieves: item id, item label, (the label of) the place of birth, and the date that any part of the item was last updated.

What if I also want to retrieve the date that the place of birth (P19) was last edited?

Thanks in advance!

Upvotes: 0

Views: 167

Answers (2)

VIGNERON
VIGNERON

Reputation: 1

Sadly, this is not possible in SPARQL.

schema:dateModified is the last modification time of the entity data (see RDF_Dump_Format), it does not work for statements (weirdly it gives a result but it's not correct).

Upvotes: 0

Place items can also have a schema:dateModified property:

SELECT ?item ?itemLabel ?item_modified ?placeofbirthLabel ?placeofbirth_modified
WHERE 
{
  
  ?item wdt:P31 wd:Q146 ;
        wdt:P19 ?placeofbirth ;
        schema:dateModified ?item_modified .
  
  ?placeofbirth schema:dateModified ?placeofbirth_modified .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
  
} LIMIT 10

Upvotes: 1

Related Questions