Understanding Temporal Functions in neo4j
Posted By : Vipul Pandey | 31-Oct-2018
In the latest version of
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
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.
example:
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"
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
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.