Skip to content

Instantly share code, notes, and snippets.

@luanschmidt
luanschmidt / random-dates.cypher
Last active March 17, 2026 19:41
Create random dates to use as a Property on Neo4J, considering the maximum amount of days in each month, not taking leap years into account.
// Using this MATCH in the beginning of the query to define the type of node you are referencing will make Neo4J iterate through
// each of them, avoiding the need to use other methods.
// startYear is the start of the year range, endYear is the end of the year range. Change to your needs as you see fit.
// Variables y and m are the random year and month generated, so you can obtain the days in the next step, that are returned as
// the variable maxDays in the end of the CASE statement
// With the SET command on line 15, you can either update or create the desired property containing the random date you just created.