Date & Math Functions

Date Functions (Extended)

date.add()

Add time to a timestamp.

Syntax: date.add(timestamp, value, unit)

Parameters:

Parameter Type Description

timestamp

Long

The timestamp (in milliseconds)

value

Long

Amount to add (can be negative)

unit

String

Unit of the value (ms, s, m, h, d)

Returns: Long - New timestamp

APOC Compatible: apoc.date.add

RETURN date.add(date.currentTimestamp(), 1, "d") AS tomorrow
// Returns: timestamp for tomorrow

RETURN date.add(date.currentTimestamp(), -1, "h") AS oneHourAgo
// Returns: timestamp for 1 hour ago

date.convert()

Convert a timestamp between units.

Syntax: date.convert(timestamp, fromUnit, toUnit)

Returns: Long - Converted timestamp

APOC Compatible: apoc.date.convert


date.currentTimestamp()

Get the current timestamp in milliseconds.

Syntax: date.currentTimestamp()

Returns: Long - Current timestamp in milliseconds since epoch

APOC Compatible: apoc.date.currentTimestamp

RETURN date.currentTimestamp() AS now
// Returns: 1705314600000 (example)

date.field()

Extract a specific field from a timestamp.

Syntax: date.field(timestamp, field)

Returns: Long - Field value

APOC Compatible: apoc.date.field


date.fields()

Extract all fields from a timestamp as a map.

Syntax: date.fields(timestamp)

Returns: Map - Map of date fields

APOC Compatible: apoc.date.fields


date.format()

Format a timestamp to a date string.

Syntax: date.format(timestamp, unit, format)

Parameters:

Parameter Type Description

timestamp

Long

The timestamp value

unit

String

Unit of the timestamp (ms, s, m, h, d)

format

String

Date format pattern (Java SimpleDateFormat)

Returns: String - Formatted date string

APOC Compatible: apoc.date.format

RETURN date.format(1705314600000, "ms", "yyyy-MM-dd HH:mm:ss") AS result
// Returns: "2024-01-15 10:30:00"

date.fromISO8601()

Parse an ISO 8601 string to timestamp.

Syntax: date.fromISO8601(dateString)

Returns: Long - Timestamp in milliseconds

APOC Compatible: apoc.date.fromISO8601

RETURN date.fromISO8601("2024-01-15T10:30:00Z") AS result
// Returns: 1705314600000

date.parse()

Parse a date string to timestamp.

Syntax: date.parse(dateString, format)

Returns: Long - Timestamp in milliseconds

APOC Compatible: apoc.date.parse


date.systemTimezone()

Get the system’s default timezone.

Syntax: date.systemTimezone()

Returns: String - Timezone ID (e.g., "America/New_York")

APOC Compatible: apoc.date.systemTimezone


date.toISO8601()

Convert a timestamp to ISO 8601 format.

Syntax: date.toISO8601(timestamp)

Returns: String - ISO 8601 formatted string

APOC Compatible: apoc.date.toISO8601

RETURN date.toISO8601(1705314600000) AS result
// Returns: "2024-01-15T10:30:00+00:00"

Math Functions (Extended)

math.cosh()

Calculate the hyperbolic cosine.

Syntax: math.cosh(x)

Returns: Double - Hyperbolic cosine value

APOC Compatible: apoc.math.cosh


math.maxDouble()

Get the maximum double value.

Syntax: math.maxDouble()

Returns: Double - Maximum double value

APOC Compatible: apoc.math.maxDouble


math.maxLong()

Get the maximum long value.

Syntax: math.maxLong()

Returns: Long - Maximum long value (9223372036854775807)

APOC Compatible: apoc.math.maxLong


math.minLong()

Get the minimum long value.

Syntax: math.minLong()

Returns: Long - Minimum long value

APOC Compatible: apoc.math.minLong


math.sigmoid()

Calculate the sigmoid function.

Syntax: math.sigmoid(x)

Returns: Double - Sigmoid value (0-1)

APOC Compatible: apoc.math.sigmoid

RETURN math.sigmoid(0) AS result
// Returns: 0.5

RETURN math.sigmoid(10) AS result
// Returns: ~0.9999

math.sigmoidPrime()

Calculate the derivative of the sigmoid function.

Syntax: math.sigmoidPrime(x)

Returns: Double - Sigmoid derivative

APOC Compatible: apoc.math.sigmoidPrime


math.sinh()

Calculate the hyperbolic sine.

Syntax: math.sinh(x)

Returns: Double - Hyperbolic sine value

APOC Compatible: apoc.math.sinh


math.tanh()

Calculate the hyperbolic tangent.

Syntax: math.tanh(x)

Returns: Double - Hyperbolic tangent value

APOC Compatible: apoc.math.tanh