-2

I have two columns on my database, sickleave and vacationleave. It has to be a decimal but for some reason I only get the whole number. For example, I input 1.50, when I press update I get the value 2. I tried setting the column type to decimal but I still get the same result.

Here's my database schema:

Schema

Renzo
  • 87
  • 1
  • 8

2 Answers2

1

From the mysql documentation:

The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments are as follows:

  1. M is the maximum number of digits (the precision). It has a range of 1 to 65.
  2. D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.

So in your case: hit change button there and in the Length/value column there should be: 11,2 with no parentheses or anything else when you hit save

In case you want to do it manually there's a discussion of it here: MySQL - How do I update the decimal column to allow more digits?

And here's the alter: ALTER TABLE YourTableName MODIFY COLUMN column_name DECIMAL(11,2);

user3647971
  • 1,069
  • 1
  • 6
  • 13
0

Tried altering it manually using:

ALTER TABLE YourTableName MODIFY COLUMN price DECIMAL(4,2);

Thanks @user3647971

Renzo
  • 87
  • 1
  • 8