ASP - Numerical Rounding topic

1
2
WriteLine "<td valign=top align=right>" & FormatCurrency(rs("UnitPrice"),2) & "&nbsp;&nbsp;</td>"
WriteLine "<td valign=top align=right>" & FormatNumber(rs("Extended"),2) & "&nbsp;&nbsp;</td>"

Issue - Extended is a calculated column
Both should render the number 219871.44

Both FormatCurrency and FormatNumber render extended as 219871.40

variations

1
2
3
4
5
' for prs 62893         
FormatCurrency(rs("UnitPrice")), FormatCurrency(rs("UnitPrice")) displays $219,871.44 , $219,871.40
FormatCurrency(rs("UnitPrice"),2), FormatCurrency(rs("UnitPrice"),2) displays $219,871.44 , $219,871.40
FormatCurrency(rs("UnitPrice")), FormatNumber(rs("UnitPrice")) displays $219,871.44 , 219,871.40
FormatCurrency(rs("UnitPrice, 2")), FormatNumber(rs("UnitPrice",2)) displays $219,871.44 , 219,871.40

I ended up changing the sql

1
2
3
4
5
6
7
8
9
strSQL =    "SELECT     Quantity, UM, PartNo, Description, UnitPrice,  " &_
            "Quantity*UnitPrice AS Extended, Comment, " &_
            "FORMAT(CONVERT(DECIMAL(18,2), Quantity * UnitPrice), 'C', 'en-US') AS ExtendedFmt " &_
            "FROM LineItems " &_
            "WHERE      requestid = @requestId " &_
            "ORDER BY LineItemID"

WriteLine "<td valign=top align=right>" & FormatCurrency(rs("UnitPrice"),2) & "&nbsp;&nbsp;</td>"
WriteLine "<td valign=top align=right>" & rs("ExtendedFmt") & "&nbsp;&nbsp;</td>"

It finally worked.