Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-07-2020 03:22 PM
Hello,
I need a way to ignore nodes where there is an error when converting a string to a date using date(). If the source string does not meet the required format, I would like cypher to skip the node instead of throwing an error. I tried also using apoc date parser but still an exception is thrown when the format is not correct.
Thank you
09-07-2020 06:55 PM
Can you share a snippet of code so we can see what you are trying to do?
09-08-2020 06:07 AM
Thank you...
match (n_1
:name_basics
)
return duration.inMonths(date({year:toInteger(substring(n_1.deathDate
,6,4)),
month:toInteger(substring(n_1.deathDate
,0,2)),
day:toInteger(substring(n_1.deathDate
,3,2))}),
date({year:toInteger(substring(n_1.birthDate
,6,4)),
month:toInteger(substring(n_1.birthDate
,0,2)),
day:toInteger(substring(n_1.birthDate
,3,2))})).months/12 as D1 limit 100
where both birthDate and deathDate are strings, and almost all are of the form MM/DD/YYYY, but there are some that are of the form DD/MM/YYYY and thus throw an error when the month is grater than 12. I would like cypher just to skip such a case and keep processing the rest.
Thanks again
09-08-2020 06:58 AM
Hello @daniel
MATCH (n_1:name_basics)
WHERE toInteger(substring(n_1.deathDate,0,2)) <= 12
AND toInteger(substring(n_1.birthDate,0,2)) <= 12
RETURN duration.inMonths(date({year:toInteger(substring(n_1.deathDate,6,4)),
month:toInteger(substring(n_1.deathDate,0,2)),
day:toInteger(substring(n_1.deathDate,3,2))}),
date({year:toInteger(substring(n_1.birthDate,6,4)),
month:toInteger(substring(n_1.birthDate,0,2)),
day:toInteger(substring(n_1.birthDate,3,2))})).months/12 AS D1 LIMIT 100
Regards,
Cobra
09-08-2020 07:40 AM
Thank you...
I will try that...
All the sessions of the conference are now available online