Skip to content

Instantly share code, notes, and snippets.

@davidrapin
Last active May 5, 2022 03:21
Show Gist options
  • Save davidrapin/05e1a2f27968e150953fe37bfcffde53 to your computer and use it in GitHub Desktop.
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"
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment