apoc.convert.toInteger

Function APOC Core Deprecated

apoc.convert.toInteger(value) | tries it’s best to convert the value to an integer

Signature

apoc.convert.toInteger(object :: ANY?) :: (INTEGER?)

Input parameters

Name Type Default

object

ANY?

null

Usage Examples

Convert string to integer
return apoc.convert.toInteger("1") AS output;
Table 1. Results
Output

1

Convert float to integer
return apoc.convert.toInteger(1.2) AS output;
Table 2. Results
Output

1

This function has been deprecated and will be removed in version 5.0. The functionality is replaced by the Neo4j functions toInteger(value) and the more permissive toIntegerOrNull(value). The Neo4j functions do not have exactly the same behavior as the APOC ones - the following table is intended to assist migration by highlighting the differences:

Table 3. Migration Path to toInteger() / toIntegerOrNull()
Input apoc.convert.toInteger() toInteger() toIntegerOrNull()

null

null

null

null

""

null

null

null

0

0

0

0

1.5

1

1

1

"1"

1

1

1

"1.5"

1

1

1

"not-a-number"

null

null

null

[1,2,3]

null

Error

null

{a:'a'}

null

Error

null

true

1

1

1

false

0

0

0

datetime("2000-01-01T00:00:00.000+0000")

null

Error

null

Node

null

Error

null

Relationship

null

Error

null

Path ()-[]-()

null

Error

null