cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Integer to string with leading zeroes

janezic
Graph Voyager

I would like to convert a property of nodes which is a integer to a string. I would use the toString()-function for that, but I need to convert them to a fixed length of the string. So there are some leading zeroes which need to be included in the string.

123 -> "123"
12 -> "012"
1 -> "001"

Is there any option for that in Cypher or Apoc?

Thank you,

JJJ

1 ACCEPTED SOLUTION

yes.. for example

 return apoc.text.lpad('1', 3, '0')

results in

001

and

 return apoc.text.lpad('123', 3, '0')

results in

123

see apoc.text.lpad - APOC Documentation for more details

View solution in original post

2 REPLIES 2

yes.. for example

 return apoc.text.lpad('1', 3, '0')

results in

001

and

 return apoc.text.lpad('123', 3, '0')

results in

123

see apoc.text.lpad - APOC Documentation for more details

Thank you, very much appreciated!

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online