Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-02-2019 03:12 PM
Using Neo4J 3.5.3, and latest APOC.
Trying to return the "latest" date among 3 date properties (in epoch ms format). I collect the properties into a collection variable, and then attempt apoc.coll.max as shown here:
MATCH (d:Mwpdevice)--(:Mwpactivestatus {state:1}) where not exists(d.deletedon)
WITH *,collect([d.lastboot,d.createdon,d.ipchanged]) as dates
WITH *,apoc.coll.max(dates) as latestdate
return latestdate
But the results for "latestdate" are just the collection:
[1536097126127,1535148519263,1535148557860]
[null,1535148519137,1535148557750]
...
Why is this not returning the single largest value of the collection? I tried tointeger() when adding to the collection, but that made no difference.
What am I doing wrong here?
03-03-2019 03:34 AM
Beause you have a double nested collection.
collect([...])
creates a list of lists.
You should use apoc.coll.max(apoc.coll.flatten(dates))
All the sessions of the conference are now available online