Comma value in properties (Europe - 12,43 - Twelve euros and fourth three cents)

Dear Everyone,

I am setting some properties on a few nodes. Here is the query I am attempting to execute.

match (i:Invoice {InvoiceNr:"1456735/2553"})
MERGE (i)-[:SUB_INVOICE]->(si:Invoice{InvoiceNr:"102435433/231",Total:197,30})

How do I get the value with the comma to ne escaped. I did a search in the manual for escape characters, but just got stuff on loading CSV data and regular expressions.

Kind regards,

Would converting it to a string first help? What's the aim of having the comma escaped?


Becasue I am building the database in europe where we use commas. So 10,20 instead of 10.20

Kind regards,

I understand that's the currency separator, but I still don't understand why you want it "escaped"?

I tried to add it to the property and Cypher thinks that everthing after the comma is a new property. So I get an error saying it is expecting a key value pair in essence. So Total: 197 and then OtherPrice: 30

So that is why I thought maybe escaping it would allow cypher to understand what I am trying to do.

You may have a better solution.

Kind regards,

Hi - are you expecting this?
match (i:Invoice {InvoiceNr:"1456735/2553"})
MERGE (i)-[:SUB_INVOICE]->(si:Invoice{InvoiceNr:"102435433/231",Total:"197,30"})

match (i:Invoice {InvoiceNr:"1456735/2553"})
MERGE (i)-[:SUB_INVOICE]->(si:Invoice{InvoiceNr:"102435433/231",Total:'197,30'})

Hello Kailash,

Does the second one allow the 197,30 to remain a number?
As I believe the first one turns it into a string. An I correct?

I need the numbers to do calculations down the line.

Kind regards,

No, Sorry . this remains as String

For clarity, both queries will turn it into string?

How do I enter it as a number?

Hi @tideon - I will let others answer but i dont think we can have comma in Int type.

Try this:

return toFloat(replace("197,30", ',', '.'))
result: 197.3

I don't believe that Neo4j has a configurable decimal separator, it recognises only .

Storing your values as strings is probably your best bet, and then if you need to perform calculations on them you can convert using toFloat on the fly e.g:

with "6,10" as firstVal, "5,10" as secondVal
return toFloat(replace(firstVal, ",", ".")) - toFloat(replace(secondVal, ",", "."))

I think you're getting caught up on the visual display of the data vs. how it needs to be stored in a database. Store it as an int 19730, and let the website/UI handle the formatting of the data. Computers don't care about local formatting. Another example of this would be a date. Different regions display dates differently but you still store the information as a date data type and handle the display formatting in the UI.

You have to manage the same on the fly only.

  1. Store 197,30 as string and change to float as mentioned by others
  2. Store as float with "." instead of ","
  3. Store as integer in 2 properties (integral, decimal) and use accordingly
    However in all the case you cannot store float value with "," .