Page 1 of 1

Comma as decimal separator

Posted: 2021-11-03 17:51
by gerardus
Hi all,

I'm using AppGini v5.98.

I have a table with 5 fields DECIMAL (12,3) and I need to be able to use comma as a decimal separator and point as thousands separator.

I tried using the format "Points for thousands and comma for decimals, 2 decimals (example: 21.345,67) that comes in the format list but it doesnt work.

If I enter the numbers with a comma as a decimal separator the number gets truncated after the comma.

e.g. 21,345 -> 21,000 and it's displayed with a point -> 21.000.

Then I don't know if the point is the decimal separator and the value is 21 or it's the thousands separator and the value is 21000.

Modifying or creating another format based on this one (FORMAT(%%FIELD%%, 3, 'de_DE') for example) doesn't work either.

With that format, using a point as a decimal separator seems to work.

Am I doing something wrong or the decimal and thousand separator thing is broken?

Re: Comma as decimal separator

Posted: 2021-11-04 11:14
by pbottcher
Hi,

as far as I remember the format you choose withing AppGini is applied for the tableview (only).

If you want to be able to enter data into your input field that allows you to enter data with thousand separator and comma as deciamal separator,
you will need to convert that within the hook (before_insert / before_update)

Also you can use javascript to display your data on the form in the way you want.

Have a look at viewtopic.php?t=4297

Re: Comma as decimal separator

Posted: 2021-11-04 11:59
by gerardus
Hi,
thanks for your reply, I'll have a look at the solution.
It may be related, do you know why calculated fields appear with more decimals than the number of decimals that are stored in the BD?
If I define a field DECIMAL (12,2) and set it as calculated, it shows with 5 digits after the decimal point both in the tableview and the detail view.
If I look at the record in the DB the value is correct, with only two decimals.

Re: Comma as decimal separator

Posted: 2021-11-04 16:13
by pbottcher
Hi,
did you try to rebuild your fields. Maybe there is a mismatching field definition.

Re: Comma as decimal separator

Posted: 2021-11-04 18:21
by gerardus
I just tried deleting the field and recreating it and it does the same. :(

Re: Comma as decimal separator

Posted: 2021-11-05 16:50
by pbottcher
Hi did you check the settings on your database for that field.

And try to run the rebuild fields to see if that gives you a hint.

Re: Comma as decimal separator

Posted: 2021-11-06 07:35
by SkayyHH
How do you actually do it with fields that are calculated? In AppGini we cannot set a data format if the field has a calculation.

I can't figure out how to set a german data format in the calculation.

Can someone give me a tip here?

The calculation is:

Code: Select all

select TIMESTAMPDIFF (day, start, end) -days_correction +1 as days from absence_de where id =% ID%
Thanks much!

Re: Comma as decimal separator

Posted: 2021-11-08 21:59
by pbottcher
Hi,

can you explain what you would expect as a result. Your statement seems to return an integer value. So where shall that be formated?

Have a look at the mysql FORMAT(myNumber, decimals, 'de_DE') statement.