Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-21-2019 06:33 PM
Hi
I am trying to subtract two dates, but am running into what I think are data type issues.
When I use the following statement:
RETURN apoc.date.convert(endDate - LAST_DATE, "ms", "d")
the following error is returned:
Neo.ClientError.Statement.TypeError: Cannot subtract
Date
fromLong
The data types for each are:
apoc.meta.type(endDate) | apoc.meta.type(LAST_DATE) |
---|---|
"INTEGER" | "LocalDate" |
endDate was created from a string:
date('2012-06-12) AS endDate
LAST_DATE was created:
WITH apoc.date.parse('12/31/2018', 'y', 'MM/dd/yyyy') AS LAST_DATE
I haven't been able to either convert endDate using apoc.date.parse to INTEGER, or use toInteger().
I appreciate any help anyone could give.
Kind regards
10-22-2019 03:58 AM
Hi!
You will need to use the duration keyword to help with that. For example, if I wanted to know the number of days between 2012-04-04 and 2011-04-05, I'd write something like this:
return duration.inDays(date("2012-04-04"), date("2011-04-05")).days
I hope that helps!
10-22-2019 04:31 AM
Hi ljubica.lazarevic
Thanks so much ! With a bit of tweaking I got my Cypher working with your help - very happy!
Kind regards
10-22-2019 06:29 AM
for those needing more details of the Neo4j temporal functions see https://neo4j.com/docs/cypher-manual/3.5/functions/temporal/duration/#functions-duration-indays
All the sessions of the conference are now available online