I have this code in my project
IFNULL((SELECT sum(Invoice) FROM labour WHERE Job_No = job.Job_No),0)AS Labsubtotal,
IFNULL((SELECT ROUND(sum(Quantity
Unit_Price+(QuantityUnit_Price
+Additional_Cost/100)),2)FROM material WHERE Job_No = job.Job_No),0)AS Matsubtotal,
(SELECT Labsubtotal+Matsubtotal)AS Subtotal,
(SELECT SubtotalVAT/100)AS VATAmount,
(SELECT Subtotal+VATAmount)AS Total,
It works great until today.
We have a subtotal of £3,750.20
This gives us a VAT amount of £656.29
But it gives us a total of £4,406.48
No, this does not add up?
The VAT amount in reality is £656.285.
I need this to either give me a VAT amount of £656.28, so I need it to round down.
Any help please?
Thanks
Paul.
Odd indeed that you didn't have this issue till today. The decimal setting is usually setup on the database itself. If you are doing so in php then well , that's your issue <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55093&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Don't know what editor you use for sql or mysql, but I suggest navicat for simplisty sake. In any case, just change the decimal value to 2 in that field you should be good at that point, the database will round this up or down for you automatically once u set it. GL!
http://dev.mysql.com/doc/refman/5.0/en/precision-math-rounding.html
edit: if you have to php u could use the round function...Thou as many I don't use php for this as it seems to have issues with negative to postive and visa versa. Just easier to do it in the database itself.
http://www.php.net/manual/en/function.round.php