Showing results for 
Search instead for 
Did you mean: 

How to compare relationship properties and update based on newer relationship?



I'm trying update all current and future properties of the relationship [:HAS_FORMER_NAME].
The properties of the relationship are two dates:

  • from - Which indicates the date of the name change
  • to - Which should be the from date of the next name change or '-' if there are no other newer [:HAS_FORMER_NAME] relationships.

The current graph structure looks as follows, where the Person and OldName nodes each contain the current and old name respectively. 


MATCH (:Person)-[p:HAS_FORMER_NAME]->(:OldName)


What im trying to do is, compare each relationship from-date and set the to-date of each relationship to the from-date of the next/newer relationship. 
If there are no new/newer changes, then the to-date should be '-'.
Can anyone help achieve this outcome?

Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.