Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

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?