Unparseable date: “NULL” with APOC.DATE.PARSE
Unparseable date: “NULL” with APOC.DATE.PARSE
I am using apoc
to calculate difference between two dates. It works when I supply value for N.ID
in the MATCH
clause. But it fails when I remove N.ID
because I am trying to process the code for a bunch of IDs not a single one.
apoc
N.ID
MATCH
N.ID
MATCH (N:PERSON)-[M:PLACED]-(K:ORDER) WHERE K.ORDER_CODE="A23" and N.ID=2511217
WITH N ,max(apoc.date.parse(SUBSTRING(M.ORDER_DATE,0,8),'d',"yyyymmdd")) AS initialTime,
apoc.date.parse(SUBSTRING(N.charge_DATE,0,8),'d',"yyyymmdd") AS finalTime
RETURN N.ID, finalTime - initialTime as difference ;
N.ID
difference
2511217 4
N.ID
However, when N.ID
is removed, I get:
N.ID
MATCH (N:PERSON)-[M:PLACED]-(K:ORDER) WHERE K.ORDER_CODE="A23"
WITH N ,max(apoc.date.parse(SUBSTRING(M.ORDER_DATE,0,8),'d',"yyyymmdd")) AS initialTime,
apoc.date.parse(SUBSTRING(N.charge_DATE,0,8),'d',"yyyymmdd") AS finalTime
RETURN N.ID, finalTime - initialTime as difference ;
Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke function apoc.date.parse
: Caused by: java.text.ParseException: Unparseable date: "NULL"
apoc.date.parse
2 Answers
2
I think its due to the aggregation function max
.
Can you try with this query :
max
MATCH (N:PERSON)-[M:PLACED]-(K:ORDER) WHERE K.ORDER_CODE="A23"
WITH
N ,
apoc.date.parse(SUBSTRING(M.ORDER_DATE,0,8),'d',"yyyymmdd") AS initialTime,
apoc.date.parse(SUBSTRING(N.charge_DATE,0,8),'d',"yyyymmdd") AS finalTime
WITH N, max(initialTime) AS initialTime, finalTime
RETURN N.ID, finalTime - initialTime as difference ;
It looks like there are multiple PERSON
nodes placing the same ORDER
, but some of them lack the charge_DATE
property needed by your query.
PERSON
ORDER
charge_DATE
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I still get the same error - with or without MAX. When I qualify the 'Where' clause with a specific ID it works, but fails when that's removed.
– AlabamaRaider
Jun 29 at 17:19