4

I am trying to retrieve all wikidata items within a latitude/longitude bounding box that have been edited in the last 24 hours

I get through the bounding box part ok, but I can't figure the "modified since" bit.

This is the closest example I could find, from which I tried to make this work:

SELECT ?place WHERE {
  SERVICE wikibase:box {
    ?place wdt:P625 ?location .
    # looks like cornerwest must be south of cornereast
    # otherwise you go around the globe
    # this is lng lat
    bd:serviceParam wikibase:cornerWest "Point(SW_LNG SW_LAT)"^^geo:wktLiteral .
    bd:serviceParam wikibase:cornerEast "Point(NE_LNG NE_LAT)"^^geo:wktLiteral .
  }
  ?place wdt:P31  ?placeCategory .
  ?place wdt:P625 ?placeCoords   .

  optional{ ?place wdt:P18 ?placePicture . }


  BIND (now() - ?modified as ?date_range)
  FILTER (?date_range > 2)
}

without results.

simone
  • 4,667
  • 4
  • 25
  • 47

1 Answers1

3

Use schema:dateModified. By the way, Blazegraph supports date and time arithmetic:

SELECT ?place ?placeLabel ?location WHERE {
  BIND ((now() - "P7D"^^xsd:duration) AS ?date_)
  SERVICE wikibase:box {
    ?place wdt:P625 ?location   .
    bd:serviceParam wikibase:cornerSouthWest "Point(55.000 55.000)"^^geo:wktLiteral.
    bd:serviceParam wikibase:cornerNorthEast "Point(65.000 65.000)"^^geo:wktLiteral.
  }
  ?place schema:dateModified ?date .
  # hint:Prior hint:rangeSafe true .
  FILTER (?date >= ?date_)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". }
}

https://w.wiki/3E9Z

There is also the wikibase:timestamp predicate which is rather auxiliary.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58