Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-12-2019 01:21 AM
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
Solved! Go to Solution.
11-13-2019 06:05 AM
11-12-2019 05:32 AM
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
11-12-2019 05:50 AM
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
11-12-2019 07:15 AM
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.
11-12-2019 09:29 AM
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.
11-13-2019 06:05 AM
Hello Andrew & Dana ,
Thanks for your valuable input.
Regards
Akshat
All the sessions of the conference are now available online