what is the {end time} for {Leland Stanford} has {position held} as {United States senator} ?
When did Leland Stanford stop being a U.S. senator?
which was the end time leland stanford who's position held in united states senator?
SELECT ?q WHERE { ?e property:position_held resource:United States senator . ?e property:end_time ?q . resource:Leland_Stanford property:position_held ?e }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q382109> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P39> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://wikidata.dbpedia.org/resource/Q13217683> .
?statement <http://www.wikidata.org/entity/P582> ?value. 
} 

SELECT ?value WHERE { wd:Q382109 p:P39 ?s . ?s ps:P39 wd:Q13217683 . ?s pq:P582 ?value}