Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-08-2020 08:00 AM
Actually I am trying to convert String formats into dates and following format occur:
2009-07-30
match(n:ENTITY)-[r:VALIDITY_PERIOD]-(m:ENTITY)
where apoc.meta.type(r.end_date) = "STRING"
and not r.end_date = "2009-07-30"
and trim(r.end_date) =~'^[0-9]{2}-[A-Z]{3}-[0-9]{4}$'
set r.end_date = date(datetime({epochmillis: apoc.date.parse(r.end_date, "ms", "dd-MMM-yyyy")})) return r;
this actually is my try to match and update format no 1.
it fails with the following error message:
Neo.ClientError.Statement.TypeError
Wrong argument type: Can't coerce `2009-07-30` to String
I tried with or without starting and ending string markes, both fail with same error.
Anyone who can help me out here?
Thank you and kindest regards,
Malte
06-08-2020 09:26 AM
I think you want the apoc.date.parseAsZonedDateTime
function:
WITH apoc.date.parseAsZonedDateTime( "2009-07-30", 'YYYY-MM-dd') AS date
RETURN date, apoc.meta.type(date), date(date), apoc.meta.type(date(date))
06-17-2020 07:08 AM
Hello Mark,
MATCH (n)-[r:VALIDITY_PERIOD]-(n)
WHERE not r.start_date = '-'
WITH apoc.date.parseAsZonedDateTime(r.start_date, 'YYYY-MM-dd') AS date
RETURN date, apoc.meta.type(date), date(date), apoc.meta.type(date(date))
trying the adapted statement above leads to the following error
Wrong argument type: Can't coerce 2005-01-26
to String
06-18-2020 06:17 AM
Hello all,
thanks a lot for researching, actually the following statement worked with serveral adaptions for each case:
match(n:ENTITY)-[r:VALIDITY_PERIOD]-(n:ENTITY)
where apoc.meta.type(r.start_date) = "STRING"
and trim(r.start_date) =~'^[0-9]{2}.*[0-9]{2}.*[0-9]{4}$'
set r.start_date = date(datetime({epochmillis: apoc.date.parse(r.start_date, "ms", "dd/MM/yyyy")}))
return r.start_date limit 5;
So problem solved:
actualy most likely the errors were caused by the part the where clause which was introduced by
and not r.end_date = "2009-07-30"
This seems to have caused the issues.
Best regards,
Malte R
All the sessions of the conference are now available online