Home > #Graph Database, Date, GraphDB, neo4j, NoSQL > Neo4j Date Functions

Neo4j Date Functions

BI BigData Readers,

Please accept my apologies for writing a new post after a long time. Lately busy with a lot of other technology-related and upgrades.

Lately working with Neo4j Graph DB to implement Customer Journey Analytics using event-based data. While implementing customer journey analytics, handled different scenarios with Neo4j dates and timestamps. This article I’ll be showcasing a couple of examples to play with dates.

By the way following Cypher code snippets from Neo4j 3.4.9. Neo4j APOC Library is really strong and most of the help available there itself. Below code samples are using some important functions from APOC. You can still play with Temporal dates

Listing some useful Cypher statements to play with date functions including date difference for your reference.


// get system timestamp in epoch format you can use following Cypher statement
RETURN timestamp();
RETURN apoc.date.currentTimestamp();

//get epoch value from date
RETURN datetime('2019-02-04').epochMillis;

//system datetime
RETURN apoc.date.format(timestamp());
RETURN apoc.date.format(timestamp(),'ms', 'yyyy-MM-dd hh-mm-ss');

//system datetime converted to Central timezone
RETURN apoc.date.format(timestamp(),'ms', 'yyyy-MM-dd hh-mm-ss','America/Chicago');

//only system date
RETURN date(apoc.date.format(timestamp(),'ms', 'yyyy-MM-dd'));

//convert Neo4j date to Central timezone
RETURN date(apoc.date.format(timestamp(),'ms', 'yyyy-MM-dd',’America/Chicago’));

//get date difference between two dates.
RETURN duration.inDays(date('2018-01-01'), date(apoc.date.format(timestamp(),'ms', 'yyyy-MM-dd',"America/Chicago"))).days;

Hope this helps.

Happy Graphing..!!!
Sandip Shinde

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.