Hi,

Friday, April 2, 2004, 2:55:41 AM, you wrote:
AH> How do I correctly display a money datatype from a mssql db?

AH> I've looked through the archives and come up empty, and google doesn't seem
AH> to have anything worth mentioning.

AH> My query is;

AH> SELECT od.price, od.inventorycost, om.totalamount

AH> FROM   orderhistorymaster as om, orderhistorydetail as od

AH> WHERE  om.ordernumber = od.ordernumber and 
AH>        om.customernumber = '$custnum' and
AH>        od.entrydate = om.entrydate and om.entrydate between
AH>        '$startdate' and '$enddate'

AH> ORDER BY om.entrydate

AH> When I run the query, for the fields 'price' and 'totalamount', I get a
AH> return of;
AH> Price
AH> 1.59149684322E-310

AH> Total Amount
AH> 5.41108926696E-309

AH> So I tried;
AH> SELECT cast(od.price as decimal(10,2)), cast(od.inventorycost as
AH> decimal(10,2)),              cast(om.totalamount as decimal(10,2))

AH> But php didn't like that.

AH> In Query Analyzer they come up;
AH> Price
AH> .7500

AH> Total Amount
AH> 25.5000

AH> My last resort would be to go into the db and do a conversion there but I
AH> really don't want to do that.
AH> How can I convert these to represent a readable dollar figure?

AH> alex hogan


AH> ******************************************************************
AH> The contents of this e-mail and any files transmitted with it are 
AH> confidential and intended solely for the use of the individual or 
AH> entity to whom it is addressed.  The views stated herein do not 
AH> necessarily represent the view of the company.  If you are not the
AH> intended recipient of this e-mail you may not copy, forward, 
AH> disclose, or otherwise use it or any part of it in any form 
AH> whatsoever.  If you have received this e-mail in error please 
AH> e-mail the sender. 
AH> ******************************************************************



I always store money values as cents in integers then /100 when I need
dollar values.

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to