cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How best to change all current isostring values to datetime with cypher

Hi, currently i have about 30 grandchild (two connections deep from root) nodes that have values that are dates as isostrings and i need to wrap all of them with datetime(). i was thinking of querying for all of them, then re-saving them wrapped in datetime(), but is there a better way? maybe a way to do it in one cypher instead of a multistep process?

1 ACCEPTED SOLUTION

ameyasoft
Graph Maven

With APOC library you can convert iso date format to date format.

Here is the Cypher script with iso date "2011-08-12T20:17:46.384Z"

RETURN apoc.date.format(apoc.date.parse("2011-08-12T20:17:46.384Z", 'ms', 'yyyy-MM-dd'), 'ms', 'MM-dd-yyyy')

Result: "08-12-2011"

View solution in original post

1 REPLY 1

ameyasoft
Graph Maven

With APOC library you can convert iso date format to date format.

Here is the Cypher script with iso date "2011-08-12T20:17:46.384Z"

RETURN apoc.date.format(apoc.date.parse("2011-08-12T20:17:46.384Z", 'ms', 'yyyy-MM-dd'), 'ms', 'MM-dd-yyyy')

Result: "08-12-2011"