How can I save and retrieve DateTime along with timezone in neo4j while creating a new node?
CREATE (n:Person {name: "John", age: 24, dob: datetime("what should be the format here")});
I am sending the format "2018-12-26T22:10:15.120+05:30" from the client.
Also how to retrieve this DateTime object as a string in any format?
You should be able to do something like this:
CREATE(n:Person {name:"John", age: 24, dob: datetime("2018-12-26T22:10:15.120+05:30")})
That'll create a datetime object in neo4j. To access the values you should be able to something like this:
MATCH(n:Person) WITH n.dob as date RETURN date.year, date.month, date.day, date.hour, date.second
Depending on your usage, in my case the Go driver that I'm using returns it as a time language in Go, the case might be similar for you. If not there is an apoc function.
MATCH(n:Person) WITH n.dob as date RETURN apoc.date.format(date.epochSeconds, 's', 'MMM d yyyy') AS dateOfBirth
2 Likes
Thank you so much, that worked for me.
1 Like