hello,
i have a field {pfs_linea} where i put the result of a datediff performed in the onvalidate event of a form.
the corresponding db field is set as DECIMAL(5,2) because i only need two digits after the floating point stored in the db.
the result of that datediff operation is often something like this: 12.66666698455810500000 because i am interested in having the differences between two dates in months instead of days so i put the datediff result in a variable and then divide the variable by 30 in order to get months.
onvalidate
if({data_progressione} != ‘null’) {
$pfs_giorni= sc_date_dif({data_progressione}, “aaaa-mm-dd”,{data_inizio_linea}, “aaaa-mm-dd”);
{pfs_linea} = $pfs_giorni/30;
}
if inside SC i set the field as “number” i don’t see decimals in the form but everything works, meaning that i don’t get errors on the form and in the db the value is stored with a value like this: 12.666 which is what i want.
But if inside SC i set the field as “decimal” in order to see decimals in the form (which is what i want), when i try to save the form i have an error (on the form) saying this:
Incorrect decimal value: ‘12,666666666667’ for column ‘pfs_linea’ at row 1
i tried to change the db field this way DECIMAL(25,20) in order to accept a high number of decimals but it gives me the same error.
I know i am doing something wrong, but what?
What is the correct approach?
Thnak you