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

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

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

return datetime(),timestamp();

returns 2 very different values and namely

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

so timestamp is a epoch style representation

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

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.

Historically we introduced datetime() along with other temporal types and temporal functions 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.

Hello Andrew & Dana ,

Thanks for your valuable input.

Regards
Akshat