I have a field that I'd like the sql code to format as currency. ie. table1.field1 = 3.34
When I show that recordset field on my web page I'd like it to look like $3.34.
Is there a way to do it in the sql?
| SitePoint Sponsor |
I have a field that I'd like the sql code to format as currency. ie. table1.field1 = 3.34
When I show that recordset field on my web page I'd like it to look like $3.34.
Is there a way to do it in the sql?


which database?
It's postgresql, with an adodb connection with php. It's currently an integer field since the "money" data type is listed is supposed to be deprecated. I'm not sure if I need to change the field type to something else or if I need to just format the sql statement to output it the way I want.


integer? then where do the cents come from?
or are you storing a value of $9.37 as 937?
use the to_char function
Thanks for the heads up on the to_char.
Regarding the field type. Yeah, I wasn't thinking with the "integer" type. I've just changed it over to "numeric" with a length of 10 and precision of 2. But whatever decimal places I type into my web form always rounds down to the .00 (zero cents). ie. .99 gets saved as 0.00 and .01 gets saved as .00(without applying any of the to_char formatting yet. This is at the actual view of the raw table). Is the "numeric" type not correct either?
Sorry, my mistake. Just a little php work to do. Thanks for the help!
Bookmarks