Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-02-2020 09:08 AM
Hi, i found out i got an issue in changing a string into a date.
In the file, the date is written as "14/12/2005"
Then, when i tried directly using r.review_date = date(a.review_date), it gave me error said Text cannot be parsed to a Date "14/12/05"
So, i research and i come up with this code:
LOAD CSV WITH HEADERS FROM "file:///ratings.csv" as l
WITH [item in split(l.review_date, "/") | toInteger(item)] AS dateComponents, l as a
WITH date({day: dateComponents[0], month: dateComponents[1], year: dateComponents[2]}) AS date, a
MERGE (r:Rating {rating_id: a.rating_id})
ON CREATE SET r.movie_id = a.movie_id,
r.movie_title = a.movie_title,
r.review_date = date
There is no error in the code but the date that i got is totally wrong. However, the date result that i get is "review_date": "0006-11-12" and here are few more result "review_date": "0097-02-06", "review_date": "0097-03-29". It changes the first 2 number of the year into 0.
Can anyone explain it to me how can i get the the right year?
11-02-2020 09:51 AM
There are a couple of ways to solve this, take a look at this article and the other way could be to use apoc functions.
11-02-2020 10:08 AM
date function wants YYYY-MM-DD. switch your dateComponents indexes
All the sessions of the conference are now available online