I have a CSV that I'm loading into Neo4j where one of the columns is a date in yyyyMMdd
format, i.e. 20210628
for June 28, 2021.
Some of the dates have '00' for the day of the month, and I would like to modify those to be '01', while leaving the dates with appropriate days-of-month as-is.
I have tried to use the approach from this blog post using FOREACH
, but the FOREACH
is matching every date as having a terminal 00
, when I know this isn't the case.
An example load statement is below.
LOAD CSV WITH HEADERS FROM 'file:///example-vertex-file__clean.csv' AS row
MERGE (p:Entity {bvd_id: row.bvd_id})
FOREACH(tmp IN CASE WHEN right(trim(row.information_date), 2) = "00" THEN [1] ELSE [] END | SET p.information_date = apoc.date.convertFormat(left(row.information_date,6) + '01', "yyyyMMdd", "yyyy-MM-dd"))
FOREACH(tmp IN CASE WHEN right(trim(row.information_date), 2) <> "00" THEN [1] ELSE [] END | SET p.information_date = apoc.date.convertFormat(row.information_date, "yyyyMMdd", "yyyy-MM-dd"))
RETURN count(p);