apoc.date.fields
Function APOC Core
apoc.date.fields('2012-12-23',('yyyy-MM-dd')) - return columns and a map representation of date parsed with the given format with entries for years,months,weekdays,days,hours,minutes,seconds,zoneid
Usage Examples
The The |
The following returns the fields of a date:
RETURN apoc.date.fields("2020-11-04", "YYYY-MM-dd") AS fields;
fields |
---|
{days: 4, zoneid: "UTC", months: 11} |
The following returns the fields of a datetime:
RETURN apoc.date.fields("2020-11-04T10:30:21", "YYYY-MM-dd'T'HH:mm:ss") AS fields;
fields |
---|
{hours: 10, seconds: 21, months: 11, minutes: 30, days: 4, zoneid: "UTC"} |
The following returns the fields of a datetime that contains a timezone:
RETURN apoc.date.fields("2020-11-04T10:30:21+01:00", "YYYY-MM-dd'T'HH:mm:ssz") AS fields;
fields |
---|
{hours: 10, seconds: 21, months: 11, minutes: 30, days: 4, zoneid: "+01:00"} |
In version 3.4 Neo4j introduced temporal data types, which are the recommended way of representing dates in Neo4j.
Fields of a temporal type can be retrieved using Cypher’s If, however, you still need to convert timestamp formats, this procedure provides that functionality. |