Get and Convert Timestamp into Date in Neo4j
Today in this article, we will cover how to Get and Convert timestamp into Date in neo4j cypher query.
We will convert the timestamp in date and also date into timestamp supporting epoch format
Let’s see below timestamp example which we will convert into a date in neo4j date.
as shown below timestamp() function gives us the current timestamp in EPOCH format.
timestamp as 1707929333554
Format timestamp into DateTime format – Neo4j
Example
datetime({epochmillis:timestamp()})
Convert Epoch timestamp into only date format – Neo4j Cypher
date(datetime({epochmillis:timestamp()}))
Example
Convert millisecond to date format
If you already have custom value then using the below command you achieve the same,
return date(datetime({epochmillis:1707929333554}))
Alternatively, one can use the below way to get the DateTime from epoch time
Get the Date from EPOCH milliseconds
You can get the Date from EPOCH milliseconds as below ,
WITH 1707929333554 as epochTime RETURN datetime({epochmillis: epochTime});
Get the Date from EPOCH seconds
You can get the Date from EPOCH seconds as below,
WITH 1614556800 as epochTime RETURN datetime({epochSeconds: epochTime});
Other References :
Do you have any comments or ideas or any better suggestions to share?
Please sound off your comments below.
Happy Coding !!
Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.