cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to get nodes between time range using relationship properties

Hello
I am trying to find nodes in hours interval such as (1am -2am),(3am-5am). I have loaded my nodes and relationships from csv files using LOAD CSV. my relationship files has a Timestamp field like this

"TIMESTAMP": "2019-06-23T18:17:24Z. there are 11 relationships and all of them have TIMESTAMP field. some of the relationship are [pays, owns,earns,wash,calls]. I want to get those nodes which performs these list of relationship in fixed time interval where the TIMESTAMP field is relationship property. each nodes has unique id. I tried DATE function but it says hours are not supported . Kindly help me to solve this. My nodes size nearly 8 million and relationship size is 1.2 billion approximately

3 REPLIES 3

You need to store the timestamp as a datetime object, then you can filter on the hour of it.

But if it's a large dataset and it's a common query I would consider making a dedicated property with "hour of day" and index it for faster range queries.

thanks for your reply. I am new in neo4j I got the idea about storing timestamp in date time. The timestamp field is a property of relationship . how could I convert relationship's TIMESTAMP property into date time object thus I can get and get the interval I am confused to build query using relationship property here

Since relationships can't be indexed, I would recommend looking into how to properly model the data based on how you're going to query it. For a small dataset, it will work fine to query on a relationship property, but if it grows it will eventually be a problem.

To store the timestamp as a datetime you need to convert it during your LOAD CSV like datetime(timestamp string)