Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-04-2020 11:04 AM
I have a simple database with person and building nodes. The relationships between these are visits with an arrival time and departure time. To start, I am attempting to build a query that shows all the arrivals that started between two datetimes.
Here is my query so far
MATCH path=(e)-[r:VISITED]->(b)
where all(rel in relationships(path) where rel.Visit_Arrive_Time > datetime({year:2020,month:5,day:30,hour:10}) and rel.Visit_Arrive_Time > datetime({year:2020,month:5,day:30,hour:13}))
return e,b
However the result appears to show more nodes and relationship than I expect:
When I run the following I get a similar result:
MATCH path=(e)-[r:VISITED {Visit_Depart_Time:datetime("2020-05-10T18:05:34Z")}]->(b) return e,b,r
I am pretty new to Neo4j so please excuse my newness. I am fairly sure that my lack is a core concept I need to review in the docs. Any input is appreciated.
Ultimately I would like to show any visit that occurred to the window between that time to a location. Then be able to show subsequent visits from those times forward.
Solved! Go to Solution.
05-04-2020 12:16 PM
Hi @rileyjenk,
Welcome to Neo4j Community!!
You do not need to use All (). When you wrote all(rel in relationships(path).... You are instructing that relationship(path) is an list, although it is not .
If you have stored rel.Visit_Arrive_Time as DateTime then try below:
MATCH (e)-[r:VISITED]->(b)
where datetime("2020-06-10T18:05:34Z")> r.Visit_Arrive_Time>datetime("2020-04-10T18:05:34Z")
return e,b
Also visit below if this is the case
05-04-2020 12:16 PM
Hi @rileyjenk,
Welcome to Neo4j Community!!
You do not need to use All (). When you wrote all(rel in relationships(path).... You are instructing that relationship(path) is an list, although it is not .
If you have stored rel.Visit_Arrive_Time as DateTime then try below:
MATCH (e)-[r:VISITED]->(b)
where datetime("2020-06-10T18:05:34Z")> r.Visit_Arrive_Time>datetime("2020-04-10T18:05:34Z")
return e,b
Also visit below if this is the case
05-04-2020 12:32 PM
Ah I see what you mean by use of the ALL statement. Thanks!
05-04-2020 12:34 PM
Ha! I am not going crazy. Wasn't sure what to look for. This really helps!
All the sessions of the conference are now available online