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.
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
However, when N.ID
is removed, I get:
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"