cancel
Showing results for 
Search instead for 
Did you mean: 

Changing and updating the key values from string datetime to datetime format

DMF194
Node Clone

Hi everyone,

This is my first time using the APOC package in neo4j.

I am trying to convert the values of my property key from string format to datetime format( eg, "2021/03/06 13:05:45.7" -> 2021/03/06T13:05:45.7

//change string datetime to object datetime
merge (p:POSITIONS)
with p.time as d
where d is not null
with apoc.date.parsed(d,'ms',"yyyy-MM-dd' 'HH:mm:ss") as r
set r= datetime({epochmillis:r})

But the error I get is

variable 'p' is not defined

Anyone have any suggestions?

3 REPLIES 3

Cobra
Ninja
Ninja

Hello @DMF194

Replace MERGE by MATCH?

Regards,
Cobra

@Cobra Hi

Tried to replace the merge with the match already.

Still same error as stated above.

Cobra
Ninja
Ninja
MATCH (p:POSITIONS)
SET (CASE WHEN p.time IS NOT NULL THEN p END).time = datetime({epochmillis: apoc.date.parse(p.time, "ms", "yyyy-MM-dd HH:mm:ss")})
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.