Jason C. Leach wrote:


In a PostgreSQL DB I have a Numeric data type with a precision of two
decimal places. If I have 1.33 in as the result from my query, it's
everything is good. However, if I have 1.30 it reduces the precision
to one decimal place and I get 1.3. Not so good when dealing with
currency ( I don't want to use the money data dype ).

Any ideas on how I can get my ZSQL method to keep two decimal places?


1.3 and 1.30 are different only in terms display and printing. One approach can be wrapping your calls to the zsql in a python script that applies formatting before returning the relavent results.

res = yourZSQL(params or request is all set up)
return "$%.2f" % res[0].yourAmountThatYouNeedToFORMAT

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to