What is {capital of} of {Ashgabat} that is {end time} is {1924-10-27} ?
What was the capital of Ashgabat until October 27th, 1924?
What was the Ashgabat capital until 10-27-1924?
SELECT ?c WHERE { ?q property:end_time ?a . resource:Ashgabat property:capital_of ?q . ?q property:capital_of ?c . FILTER ( CONTAINS ( YEAR ( ?a ) , '1924' ) ) }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q23438> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P1376> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P582> <1924-10-27>
} 

SELECT ?obj WHERE { wd:Q23438 p:P1376 ?s . ?s ps:P1376 ?obj . ?s pq:P582 ?x filter(contains(YEAR(?x),'1924')) }