What is {position held} of {Valentín Gómez Farías} that is {end time} is {1833-6-18} ?
Until 1883, which position was held by Valentin Gomez Farias?
What position did Valentin Gomez Farias hold until year 1833?
SELECT ?d WHERE { ?w property:end_time ?g . resource:Valentín_Gómez_Farías property:position_held ?w . FILTER ( CONTAINS ( YEAR ( ?g ) , '1833' ) ) . ?w property:position_held ?d }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q358534> .
?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> ?obj .
?statement <http://www.wikidata.org/entity/P582> <1833-6-18>
} 

SELECT ?obj WHERE { wd:Q358534 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P582 ?x filter(contains(YEAR(?x),'1833')) }