Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-06-2019 06:46 AM
Hello everyone,
I'm trying to build temporal query which I'd use for analysing incidences over time. This code fails, where I'd expect comparison of list against list to work as in usual languages:
with LocalDateTime("2018-01-01") as date, duration({months: 1}) AS duration
unwind range(0, 14) as range
with [collect(date + range*duration), collect(date + (range + 1)*duration)] as periods
return periods[1]<periods[2]
Let's say I have this graph:
(:Person{name})-[:WATCHED{when}]->(:Movie)-[:HAS_GENRE]->(:Genre)
I'd like to write query trend for what has person watched each month. Does anyone have an idea how to do it? I have code which uses driver and will do that query for every month separately, but I'd like to do it in "one shot". Is that possible?
Regards!
09-09-2019 03:20 PM
You don't need the collect.
with LocalDateTime("2018-01-01") as date, duration({months: 1}) AS duration
unwind range(0, 14) as range
with [date + range*duration, date + (range + 1)*duration] as periods
return periods[0]<periods[1], periods[0],periods[1]
You don't even need the array:
with LocalDateTime("2018-01-01") as date, duration({months: 1}) AS duration
unwind range(0, 14) as range
with date + range*duration as p1, date + (range + 1)*duration as p2
return p1, p2, p1 < p2
All the sessions of the conference are now available online