apoc.date.convert

Function APOC Core

apoc.date.convert(12345, 'ms', 'd') convert a timestamp in one time unit into one of a different time unit

Signature

apoc.date.convert(time :: INTEGER?, unit :: STRING?, toUnit :: STRING?) :: (INTEGER?)

Input parameters

Name Type Default

time

INTEGER?

null

unit

STRING?

null

toUnit

STRING?

null

Usage Examples

The unit and toUnit parameters support the following values:

  • ms, milli, millis, milliseconds

  • s, second, seconds

  • m, minute, minutes

  • h, hour, hours

  • d, day, days

The computed value will be in the unit specified by the unit parameter.

The following converts 30 minutes into seconds:

RETURN apoc.date.convert(30, "minutes", "seconds") as outputInSeconds;
Table 1. Results
outputInSeconds

1800

The following converts the current datetime in epoch seconds into the number of days since 1st January 1970:

RETURN apoc.date.convert(datetime().epochSeconds, "seconds", "days") as outputInDays;
Table 2. Results
outputInDays

18571