Skip to content

Instantly share code, notes, and snippets.

@davidrapin
Last active March 17, 2026 19:41
Show Gist options
  • Select an option

  • Save davidrapin/05e1a2f27968e150953fe37bfcffde53 to your computer and use it in GitHub Desktop.

Select an option

Save davidrapin/05e1a2f27968e150953fe37bfcffde53 to your computer and use it in GitHub Desktop.
Create random dates (Neo4j Cypher)
// amount: number of random dates to create
// startYear: year range start
// startYear: year range end
WITH 1000 as amount, 2017 as startYear, 2021 as endYear
WITH range(1, amount) as xx, startYear, (endYear - startYear) as yearRange
UNWIND xx as x
WITH date({
year:toInteger(1+startYear+floor(rand()*yearRange)),
month:toInteger(1+floor(rand()*12)),
day:toInteger(1+floor(rand()*27))
}) as d
RETURN d
"2020-10-05"
"2021-11-04"
"2021-11-03"
"2018-05-11"
"2018-05-23"
"2019-09-18"
"2021-11-22"
"2021-08-04"
"2019-05-07"
"2018-09-14"
"2021-07-10"
"2018-05-13"
"2019-09-10"
"2021-08-05"
"2018-06-08"
"2020-08-17"
"2021-04-20"
"2021-04-27"
"2020-10-04"
"2020-01-06"
"2020-02-03"
"2021-05-04"
"2019-06-05"
"2020-06-01"
"2021-10-01"
"2021-04-04"
"2018-11-19"
[...]
@luanschmidt
Copy link
Copy Markdown

Hi David, thank you for this gist. I am currently learning a bit of graph data analysis using Neo4J and used it. I actually tried and created my query removing the limitation on the days, so it goes until the maximum amount of days of each month, and created my own gist about it. Thanks again, and all the best to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment