apoc.date.convert

Details

Syntax

apoc.date.convert(time, unit, toUnit)

Description

Converts the given timestamp from one time unit into a timestamp of a different time unit.

Arguments

Name

Type

Description

time

INTEGER

The timestamp to be converted.

unit

STRING

The unit the given timestamp is in.

toUnit

STRING

The unit to convert the given timestamp to.

Returns

INTEGER

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;
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;
Results
outputInDays

18571