convert a string to date format for relationship property with neo4j

Viewed 24

I'm working with neo4j in order to construct a graph like that :enter image description here all that information are imported from a csv file containing (username,nationality,date_travel,location_name,geolocalisation) The problem is when I try to convert date from string format to date format, when trying this code it doesn't work :enter image description here ps1: the format of date is "m/d/yy". ps2: I'm a beginner so that my question should look stupid, thank you in advance.

1 Answers

Below will update your t.date from string to date format.

MATCH (n:user)-[t:to]->(l:location) 
WITH t, [item in split(t.date, "/") | toInteger(item)] AS dateComponents
SET t.date = date({day: dateComponents[1], month: dateComponents[0], year: 2000+dateComponents[2]})  

Note: usually, nodes are defined as User or Location rather than user, location. Then properties are in lower case like t.date instead of t.Date.

Related