Understanding Temporal Functions in neo4j

Posted By : Vipul Pandey | 31-Oct-2018

In the latest version of cypher(3.4) it provides user allowing for the creation and updating of each type of values like — Date, Time, LocalTime, DateTime, LocalDateTime and Duration.
Each of the functions of neo4j has the same capabilities as the type depicts and they are

Date — made up of Date (conceptually year, month and day).
Time — made by using a Time property viz (hour, minute, second, and sub-seconds).The subsecond is further divided into 3 parts namely millisecond, microsecond and nanosecond.

DateTime — as the name suggests it is made by combining above(date+time) .NOTE: if the type is created and the type from which the time component is being selected both contain timezone (and a timezone is not explicitly specified) the timezone is also selected.

LocalDateTime - it is also made by date and time but doesn't contain the timezone.
Duration -- It can be used to construct a Duration object from a map of its components in the same way as the temporal instant types.
eg: duration([ {years, quarters, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds} ])
All the neo4j's temporal instant types with or without timezone allow timezone to be specified for function and also supports the current instant in a specified time zone.


 If we want the current datetime from cypher return datetime() as currentDateWithTime;                     output    "2018-10-31T16:00:40.011000000Z"
 If we want the only current date from cypher return date() as todaysDate;                                 output    "2018-10-31"
 If we want the only current time from cypher return time() as currentTime;                                output    "16:01:47.270000000Z"  
 If we want the only current datetime in milliseconds from cypher return timestamp() as currentInstant;    output    1541001734159
 To construct date with time from miliseconds return dateTime({epochmillis:timestamp()})                   output    "2018-10-31T16:02:43.958000000Z"
 To construct date with time from miliseconds return date(dateTime({epochmillis:timestamp()}))             output    "2018-10-31"

About Author

Author Image
Vipul Pandey

Vipul Pandey is a good team-player & developing application on MEAN and java spring boot. Vipul loves to keep rotating fingers in his keyboard until he creates somethings inspiring.Hobbies are playing cricket ,swimming & photography.

Request for Proposal

Name is required

Comment is required

Sending message..