what is the {end time} for {Mahatma Gandhi} has {residence} as {South Africa} ?
On what date did Mahatma Gandhi leave his residence from South America?
When did Mahatma Gandhi leave his residence from South Africa?
SELECT ?i WHERE { ?f property:end_time ?i . ?f property:residence resource:South_Africa . resource:Mahatma_Gandhi property:residence ?f }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q1001> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P551> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://wikidata.dbpedia.org/resource/Q258> .
?statement <http://www.wikidata.org/entity/P582> ?value. 
} 

SELECT ?value WHERE { wd:Q1001 p:P551 ?s . ?s ps:P551 wd:Q258 . ?s pq:P582 ?value}