What is {spouse} of {Jim Carrey} that is {end time} is {1997-1-1} ?
Who did Jim Carrey divorce in 1997?
Who was the spouse of Jim Carrey prior to their divorce in 1997?
SELECT ?i WHERE { ?b property:spouse ?i . FILTER ( CONTAINS ( YEAR ( ?b ) , '1997' ) ) . resource:Jim_Carrey property:spouse ?b . ?b property:end_time ?b }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q40504> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P26> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P582> <1997-1-1>
} 

SELECT ?obj WHERE { wd:Q40504 p:P26 ?s . ?s ps:P26 ?obj . ?s pq:P582 ?x filter(contains(YEAR(?x),'1997')) }