I want age property to automatically count up on April 1 every year

Hi,

I am new to Neo4j and Cypher. Currently I am using Neo4j Desktop and try to develop my company's internal system.

Now, there are multiple Employee nodes have age property. I want all age property to automatically count up on April 1 every year.
Do you have any idea to solve this issue?

Thanks in advance.

@taichi_kawakami

I think it is possible to use the APOC trigger to update to April.
Better yet, if you have a birthday property then you don't need to handle the count up.

Never ever try to save in a database a state which is changing all the time. Go for the "fixed point in the universe".
You may save someone's birthday, then you will be able to get his/her age at every time.

Thank you for replying.

Actually I want to add birthday as property, but I can' t do it from perspective of personal information security. So there are no other way but to add age property.
I know I can use apoc trigger, but I don't know how to run Cypher statement to automatically count up age property. So Would you tell me how to do it?

@taichi_kawakami

You can use the simple solution.
If you don't know their birthday and you want to add their age on April 1, just make all their birthdays on April 1.

1 Like

I see.my issue is solved! Thank you!

@taichi_kawakami

You can use the date function like this.

MATCH (n:Person)
SET n.birthday = date('1990-04-01')
1 Like