I have the following code:
MATCH (c1:City),(c2:City)
WHERE c1.name= 'London' AND c2.name = 'Luton'
CREATE (c2)<-[:LIVING_IN {date_of_start: 2019}]-(p:Person {name: 'Mark'});
MATCH (c1:City),(p:Person)
WHERE c1.name= 'Luton' AND p.name = 'Mark'
CREATE (p)-[:WORKING_IN {date_of_start: 2019, date_of_end: 2021}]->(c1);
MATCH (c1:City),(p:Person)
WHERE c1.name= 'London' AND p.name = 'Mark'
CREATE (p)-[:WORKING_IN {date_of_start: 2022}]->(c1);
The code defines that person has started living in a cerain city in certain year. That same person has changed the city where the work is done.
For one node I have the end date (date_of_end: 2021}
), but another I don't since the work is still going on.
How can I calculate the years on the job at the latest location if I don't have year as node property?