# How to fetch the data which is 2 hr old

**URL:** <https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037>\
**Category:** Cypher\
**Created:** [February 13, 2019, 12:43pm UTC](https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037 "2019-02-13T12:43:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanmoymoulik](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tanmoymoulik/32/3196_2.png) [@tanmoymoulik](https://community.neo4j.com/u/tanmoymoulik)\
**Post date:** [February 13, 2019, 12:43pm UTC](https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037/1 "2019-02-13T12:43:33Z")

</div>

Dear All,

I am new to neo4j.FOr my project I have uploaded the data in ne04j.I have added created\_time and modified\_time as 2 property of the node.Now i want to build cypher query which would pull old those data which are modified 2 hr before.Can you share sample scirpt which would be helpful for me to fetch the data.

---

<div class="post-metadata">

**Author:** ![pdrangeid](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/pdrangeid/32/7914_2.png) [@pdrangeid](https://community.neo4j.com/u/pdrangeid)\
**Post date:** [February 14, 2019, 12:58am UTC](https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037/2 "2019-02-14T00:58:03Z")

</div>

How did you store your dates? As date/time string, or did you use timestamp()? If you used timestamp, you could do something like this:  
With (Timestamp()- 7200000) as newerthan  
MATCH (n:label) where n.modified\_time \< newerthan  
Return n

Couldn't test this, as I'm on my mobile right now

---

<div class="post-metadata">

**Author:** ![tanmoymoulik](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tanmoymoulik/32/3196_2.png) [@tanmoymoulik](https://community.neo4j.com/u/tanmoymoulik)\
**Post date:** [February 14, 2019, 6:02am UTC](https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037/3 "2019-02-14T06:02:20Z")

</div>

> [@pdrangeid](#):
>
> As date/time string, or did you

I had stored the date in timestamp format.Thanks for suggestion Let me test confirm.

Thanks

---

<div class="post-metadata">

**Author:** ![tanmoymoulik](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tanmoymoulik/32/3196_2.png) [@tanmoymoulik](https://community.neo4j.com/u/tanmoymoulik)\
**Post date:** [February 14, 2019, 6:10am UTC](https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037/4 "2019-02-14T06:10:22Z")

</div>

Hi Paul,

I did tried but it not working.Actually I had stored the time in datetime().So the above condition is not working.Can you suggest how can we fetch data which are last modified say 8 hr before from current time.

---

<div class="post-metadata">

**Author:** ![pdrangeid](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/pdrangeid/32/7914_2.png) [@pdrangeid](https://community.neo4j.com/u/pdrangeid)\
**Post date:** [February 14, 2019, 4:02pm UTC](https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037/5 "2019-02-14T16:02:09Z")

</div>

With (Timestamp()- 28800000) as olderthan  
MATCH (n:Mynode) where datetime(n.modifiedtime).epochmillis \< olderthan  
return n

This will return nodes that were modified MORE THAN 8 hours prior to right now.

You may find it more convenient to store your timestamps converted to epoch, which makes it easier/faster to perform compare operations on them in your where clauses

---

<div class="post-metadata">

**Author:** ![tanmoymoulik](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tanmoymoulik/32/3196_2.png) [@tanmoymoulik](https://community.neo4j.com/u/tanmoymoulik)\
**Post date:** [February 16, 2019, 10:02am UTC](https://community.neo4j.com/t/how-to-fetch-the-data-which-is-2-hr-old/5037/6 "2019-02-16T10:02:35Z")

</div>

Thanks for the solution Paul.
