'append decimal point in the middle of integer in postgres
I'm doing a report from our database regarding some amount
It shows like this in the report from the front end
however in the backend it's like this
It seems that the system adds a decimal point before the last two digits of the entries I've check the other ones and this seems to be the case
My question is, is there a function that I can use to append a decimal point before the last two digits whenever I generate the report in postgres?or is there another way to achieve the same result?
So I can provide a backend report that shows the same as the front end
Solution 1:[1]
Assuming the amount
values are actually in cents, you should be able to just divide by 100:
SELECT expense_date, CAST(amount / 100.0 AS money) AS money
FROM yourTable;
Also, you may wish to handle this formatting issues in your presentation layer rather than directly on Postgres.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |