apoc.date.field
Syntax |
|
||
Description |
Returns the value of one field from the given date time. |
||
Arguments |
Name |
Type |
Description |
|
|
The timestamp in ms since epoch to return a field from. |
|
|
|
The unit of the field to return the value of. The default is: |
|
|
|
The timezone the given timestamp is in. The default is: |
|
Returns |
|
Accessing temporal fields using Cypher
Fields of a temporal type can be retrieved using Cypher’s instance.field
component access.
RETURN datetime().year
Fields can also be accessed dynamically:
RETURN datetime()[$fieldNameAsParam]
Usage Examples
The
The computed value will be in the unit specified by the |
The following examples return the hours of a datetime using both APOC and Cypher:
WITH datetime("2020-11-04T10:30:00").epochMillis AS datetime
RETURN apoc.date.field(datetime, "hours") AS hour;
WITH datetime("2020-11-04T10:30:00") AS datetime
RETURN datetime.hour AS hour;
hour |
---|
10 |
The following examples return the weekday of a datetime using both APOC and Cypher:
WITH datetime("2020-11-04T10:30:00").epochMillis AS datetime
RETURN apoc.date.field(datetime, "weekday") AS weekday;
WITH datetime("2020-11-04T10:30:00") AS datetime
RETURN datetime.dayOfWeek AS weekday;
weekday |
---|
3 |