'Convert datetime to timestamp in Neo4j
How to convert datetime in data loaded in Neo4j to timestamp? Example datetime format: 2020-04-07T12:39:38.027Z Please assist.
Solution 1:[1]
Neo4's temporal instants (like datetime
) have a special variable, epochMillis, that provides the equivalent epoch time.
For example:
RETURN datetime('2020-04-07T12:39:38.027Z').epochMillis
returns
1586263178027
Solution 2:[2]
You can convert a DateTime to a string by first converting it to a timestamp with epochMillis and passing that to the apoc.date.toISO8601
function.
WITH datetime() as dt
RETURN apoc.date.toISO8601(dt.epochMillis, "ms") AS iso8601
returns
"2022-04-30T18:56:53.145Z"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | cybersam |
Solution 2 | Dan Christos |