-1

How to convert datetime in data loaded in Neo4j to timestamp? Example datetime format: 2020-04-07T12:39:38.027Z Please assist.

  • DateTime is a datatype. Timestamp field is used to record the instant when an event occurred. Timestamp field can be of any datatype such as DateTime. – Vihang Patil May 31 '20 at 08:47

2 Answers2

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
cybersam
  • 63,203
  • 6
  • 53
  • 76
0

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"
Dan Christos
  • 71
  • 1
  • 2