Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-20-2018 04:02 AM
Cypher now has great support for creating and comparing date time instances. Can we expect to see new functions for formatting these?
11-20-2018 08:39 AM
Have you had a look at the APOC date parsing/formatting functions?
11-20-2018 08:41 AM
Hi taffyb,
You should be able to use the apoc library methods: apoc.date.parse() and apoc.date.format() to achieve what you are looking for.
As an example, to convert the current timestamp in epoch that is returned by timestamp()
function to a friendly format, you could do
WITH apoc.date.format( timestamp(), 'yyyyMMdd HH:mm:ss.ms') AS initialTime RETURN initialTime
Documentation can be found here: https://neo4j-contrib.github.io/neo4j-apoc-procedures/
11-20-2018 09:09 AM
Yes I have used apoc to do this. However currently (as far as I can tell) it requires me to get the timestamp or epoch value then format. I was hoping there might be something a bit more native.
11-20-2018 09:18 AM
You can declare dates in UTC format and get it back as epoch as well using datetime().
WITH datetime('2015-07-21T21:40:32.142+0100') AS date1 RETURN date1.epochMillis
I am not sure what your exact use-case is, but to feed a date into a query you have to use one of these formats:
WITH datetime({ year:1984, month:11, day:11, hour:12, minute:31, second:14, nanosecond: 645876123, timezone:'Europe/Stockholm' })
11-20-2018 02:51 PM
Hi taffyb,
This is something we'd like to see for our native temporal types, as the date formatting for APOC is convenient.
I believe this is on our backlog, though I'll confirm (and make sure it is if not).
11-20-2018 11:21 PM
Andrew
Native formating seems to be a natural addition. However changes to the apoc routines to accept temporal types as input might be another approach.
All the sessions of the conference are now available online