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.

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"

1 Like

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