You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into an issue where I'm sending a value of 333.34 as TediousType.Money (using addParam) and it's saving to SQL as 333.3399.
In my scenario:
Im taking the monetary amount of $1,000. Dividing that by 3 buckets, which yields 333.33. I write an entry to a SQL table (along with other properties) for that, except for third entry (since that would otherwise equal 999.99). I instead add a penny to that third entry, and then make a sql entry.
I arrive at a penny (not a magic number), by subtracting the running total before writing the last entry from the monetary amount. So Math.Round(1000-999.99*100)/100 to arrive at $0.01.
I then add the penny by
function truncateNumber(number) { return Math.trunc(number*100) / 100 }
var num1 = 333.33 * 100
var num2 = .01 * 100
var total = truncateNumber(num1 + num2) / 100 <== equals 333.34
Saving that value using TediousType.Money, to a SQL Field of type Money, will store the value as 333.3399.
My current workaround is to use TediousType.Float with precision 2, but this is undesireable as the SQL field is of type Money.
The text was updated successfully, but these errors were encountered:
This happens because 333.34 needs to be multiplied by 10^4 before sending it to SQL Server (according to TDS spec), and 333.34 * 10000 = 3333399.9999999995 in js 😞 #678 has details on the plan to fix the datatype issues.
I'm running into an issue where I'm sending a value of 333.34 as TediousType.Money (using addParam) and it's saving to SQL as 333.3399.
In my scenario:
Im taking the monetary amount of $1,000. Dividing that by 3 buckets, which yields 333.33. I write an entry to a SQL table (along with other properties) for that, except for third entry (since that would otherwise equal 999.99). I instead add a penny to that third entry, and then make a sql entry.
I arrive at a penny (not a magic number), by subtracting the running total before writing the last entry from the monetary amount. So
Math.Round(1000-999.99*100)/100
to arrive at $0.01.I then add the penny by
Saving that value using TediousType.Money, to a SQL Field of type Money, will store the value as 333.3399.
My current workaround is to use TediousType.Float with precision 2, but this is undesireable as the SQL field is of type Money.
The text was updated successfully, but these errors were encountered: