mysql decimal fromat like ##.##
-
I have decimal(10,2) table column, is there way to format it like if you have 10.02 it will display 10.02 then if you 10.50 it will display 10.5. It look like that format of .ToString("##.##") in c#. BTW this is on MySQL. I just want to omit the last zero of the decimal. I will appreciate for any help will come.
-
I have decimal(10,2) table column, is there way to format it like if you have 10.02 it will display 10.02 then if you 10.50 it will display 10.5. It look like that format of .ToString("##.##") in c#. BTW this is on MySQL. I just want to omit the last zero of the decimal. I will appreciate for any help will come.
Where will the number display, in a report, in a browser, in a Windows Form?
The difficult we do right away... ...the impossible takes slightly longer.
-
I have decimal(10,2) table column, is there way to format it like if you have 10.02 it will display 10.02 then if you 10.50 it will display 10.5. It look like that format of .ToString("##.##") in c#. BTW this is on MySQL. I just want to omit the last zero of the decimal. I will appreciate for any help will come.
If you convert it to float and then round in SQL it would work as you need. check this
declare @no float=10.20
select Round(@no,2)i have executed it in sql server, so check if that works in My SQL or not
Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).
-
If you convert it to float and then round in SQL it would work as you need. check this
declare @no float=10.20
select Round(@no,2)i have executed it in sql server, so check if that works in My SQL or not
Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).
Thank you for your response but, it doesn't seems will work on MySql
-
Where will the number display, in a report, in a browser, in a Windows Form?
The difficult we do right away... ...the impossible takes slightly longer.
Actually it will be used in windows forms.
-
Thank you for your response but, it doesn't seems will work on MySql
did you tried it
Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).
-
did you tried it
Mark the answer as accepted if that worked for you :). And for down-voters please specify the reason to improve the solution :).
Yes I did, but there is no way I can cast decimal to float. I did a work around but it is ugly, it could cause a performance issue, so I am still looking for a better solution.