
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

DELETE { ?s ?p ?val . }
INSERT { ?s ?p ?typed . }
WHERE {
  VALUES ?p {
    <http://example.org/migrants/person#birthdate>
    <http://example.org/migrants/person#birthdate_max>
    <http://example.org/migrants/person#deathdate>
    <http://example.org/migrants/person#deathdate_max>
    <http://example.org/migrants/work#DateStart_Min>
    <http://example.org/migrants/work#DateStart_Max>
    <http://example.org/migrants/work#DateEnd_Min>
    <http://example.org/migrants/work#DateEnd_Max>
    <http://example.org/migrants/migration_table#DateStart_Min>
    <http://example.org/migrants/migration_table#DateStart_Max>
    <http://example.org/migrants/migration_table#DateEnd_Min>
    <http://example.org/migrants/migration_table#DateEnd_Max>
    <http://example.org/migrants/personnames#DateStart_Min>
    <http://example.org/migrants/personnames#DateStart_Max>
    <http://example.org/migrants/personnames#DateEnd_Min>
    <http://example.org/migrants/personnames#DateEnd_Max>
    <http://example.org/migrants/relationship#DateStart_Min>
    <http://example.org/migrants/relationship#DateStart_Max>
    <http://example.org/migrants/relationship#DateEnd_Min>
    <http://example.org/migrants/relationship#DateEnd_Max>
    <http://example.org/migrants/religions#date_start>
    <http://example.org/migrants/religions#DateStart_Min>
    <http://example.org/migrants/religions#DateStart_Max>
    <http://example.org/migrants/religions#DateEnd_Min>
    <http://example.org/migrants/religions#DateEnd_Max>
  }
  ?s ?p ?val .
  FILTER(REGEX(STR(?val), "^\\d{4}-\\d{2}-\\d{2}$"))
  BIND(STRDT(STR(?val), xsd:date) AS ?typed)
}
