cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Order results by unix date command strings using apoc

I'm trying to find how I can order my output by date when I have dates that are in the string format produced by the unix date command. I would like to say something like

  ORDER BY apoc.date.unix(Date)

The unix data command produces a string that looks like:

Mon Apr 29 19:01:53 UTC 2019

I've upgraded my Neo4j Community addition to the most recent in order to get the temporal functions. These seem to address a similar but different problem. I've now installed APOC but haven't found among the functions there a solution to my problem.

2 REPLIES 2

ameyasoft
Graph Maven

Try this:

RETURN apoc.date.format(apoc.date.parse("Mon Apr 29 19:01:53 UTC 2019", 'ms', 'E MMM dd HH:mm:ss Z yyyy'), 'ms', 'MM-dd-yyyy');

Result: "04-29-2019"

Thank you. This is very helpful.
I changed the date.format to 'yyyy-MM-dd HH:mm:ss' to get the order just right.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online