# How to get nodes between time range using relationship properties

**URL:** <https://community.neo4j.com/t/how-to-get-nodes-between-time-range-using-relationship-properties/13344>\
**Category:** Cypher\
**Tags:** cypher\
**Created:** [January 5, 2020, 8:58am UTC](https://community.neo4j.com/t/how-to-get-nodes-between-time-range-using-relationship-properties/13344 "2020-01-05T08:58:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kalyan\_b\_aninda](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/kalyan_b_aninda/32/6079_2.png) [@kalyan\_b\_aninda](https://community.neo4j.com/u/kalyan_b_aninda)\
**Post date:** [January 5, 2020, 8:58am UTC](https://community.neo4j.com/t/how-to-get-nodes-between-time-range-using-relationship-properties/13344/1 "2020-01-05T08:58:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thomas\_Silkjaer](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/thomas_silkjaer/32/2476_2.png) [@Thomas\_Silkjaer](https://community.neo4j.com/u/Thomas_Silkjaer)\
**Post date:** [January 5, 2020, 9:36am UTC](https://community.neo4j.com/t/how-to-get-nodes-between-time-range-using-relationship-properties/13344/2 "2020-01-05T09:36:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kalyan\_b\_aninda](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/kalyan_b_aninda/32/6079_2.png) [@kalyan\_b\_aninda](https://community.neo4j.com/u/kalyan_b_aninda)\
**Post date:** [January 5, 2020, 9:56am UTC](https://community.neo4j.com/t/how-to-get-nodes-between-time-range-using-relationship-properties/13344/3 "2020-01-05T09:56:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thomas\_Silkjaer](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/thomas_silkjaer/32/2476_2.png) [@Thomas\_Silkjaer](https://community.neo4j.com/u/Thomas_Silkjaer)\
**Post date:** [January 5, 2020, 10:04am UTC](https://community.neo4j.com/t/how-to-get-nodes-between-time-range-using-relationship-properties/13344/4 "2020-01-05T10:04:42Z")

</div>

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)`
