# What is the difference between datetime() and timestamp() in Neo4j and for what purpose both these functions are used?

**URL:** <https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819>\
**Category:** Cypher\
**Created:** [November 12, 2019, 9:21am UTC](https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819 "2019-11-12T09:21:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshat\_mittal](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akshat_mittal/32/4359_2.png) [@akshat\_mittal](https://community.neo4j.com/u/akshat_mittal)\
**Post date:** [November 12, 2019, 9:21am UTC](https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819/1 "2019-11-12T09:21:33Z")

</div>

Hello Team,

I want to have some understanding on the below query:  
What is the difference between datetime() and timestamp() in Neo4j and for what purpose both these functions are used?

Thanks in Advance!

Regards  
AK

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [November 12, 2019, 1:32pm UTC](https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819/2 "2019-11-12T13:32:01Z")

</div>

though you do not specify the Neo4j version, and I'm not suspecting it matters much but when using Neo4j running 3.5.x

```auto
return datetime(),timestamp();

```

returns 2 very different values and namely

```auto
"2019-11-12T13:29:21.752000000Z" 1573565361752

```

so timestamp is a epoch style representation

---

<div class="post-metadata">

**Author:** ![akshat\_mittal](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akshat_mittal/32/4359_2.png) [@akshat\_mittal](https://community.neo4j.com/u/akshat_mittal)\
**Post date:** [November 12, 2019, 1:50pm UTC](https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819/3 "2019-11-12T13:50:39Z")

</div>

Hello Dana,

I am using 3.5.3 version installed on Linux.  
Yes , It is running 2 different values.  
May I know when we can use these functions or for what is the use-case for these functions?

Regards  
AK

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [November 12, 2019, 3:15pm UTC](https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819/4 "2019-11-12T15:15:09Z")

</div>

As to usage, this is more up to you and hard to say when one is more appropriate than the other.  
If for example you have a UI which prompts a user for a date, and they enter a human readable date, i.e.. 2019-11-12, then maybe you want to record the data in node property as a datetime(). If however they enter the date as 2019-11-12 and you then convert it to a epoch format maybe you want to record the data in a node property as timestamp().  
Its really up to you.

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [November 12, 2019, 5:29pm UTC](https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819/5 "2019-11-12T17:29:23Z")

</div>

Historically we introduced `datetime()` along with other [temporal types](https://neo4j.com/docs/cypher-manual/current/syntax/temporal/) and [temporal functions](https://neo4j.com/docs/cypher-manual/current/functions/temporal/) in Neo4j 4.0 in May of 2018.

Prior to this we only had `timestamp()` for the ms offset, and had functions in APOC for parsing and formatting based on the ms timestamp.

So as Dana mentioned it is up to you how you want to interact with and manipulate temporal values. APOC still works a bit better for custom parsing and formatting options, but the temporal types and functions are newer and have index support, if you do index a temporal property on a node.

---

<div class="post-metadata">

**Author:** ![akshat\_mittal](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akshat_mittal/32/4359_2.png) [@akshat\_mittal](https://community.neo4j.com/u/akshat_mittal)\
**Post date:** [November 13, 2019, 2:05pm UTC](https://community.neo4j.com/t/what-is-the-difference-between-datetime-and-timestamp-in-neo4j-and-for-what-purpose-both-these-functions-are-used/11819/6 "2019-11-13T14:05:06Z")

</div>

Hello Andrew & Dana ,

Thanks for your valuable input.

Regards  
Akshat
