RE: [PHP] Displaying a money datatype from mssql - Solution

2004-04-02 Thread Alex Hogan
Recap:
In the query I had;
SELECT totalamount

And it was returning;
Total Amount
5.41108926696E-309

I tried to modify the query to;
SELECT cast(totalamount as decimal(10,2)) as totalamount

And php gave me an error;
Undefined Index at line (x);

When I tried to use 'number_format($totalamount,2)' it returned;
Total Amount
0.00

Solution:
The solution was in the query;
SELECT cast(totalamount as numeric(10,2)) as totalamount

This returns the proper formatting;
Total Amount
123.50



alex hogan


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




RE: [PHP] Displaying a money datatype from mssql - Solution

2004-04-02 Thread Frank M. Kromann
This is a bug in php 4.3.5 and it's fixed in the upcomming 4.3.6 release.

- Frank

 Recap:
 In the query I had;
 SELECT totalamount
 
 And it was returning;
 Total Amount
 5.41108926696E-309
 
 I tried to modify the query to;
 SELECT cast(totalamount as decimal(10,2)) as totalamount
 
 And php gave me an error;
 Undefined Index at line (x);
 
 When I tried to use 'number_format($totalamount,2)' it returned;
 Total Amount
 0.00
 
 Solution:
 The solution was in the query;
 SELECT cast(totalamount as numeric(10,2)) as totalamount
 
 This returns the proper formatting;
 Total Amount
 123.50
 
 
 
 alex hogan
 
 
 ** 
 The contents of this e-mail and any files transmitted with it are 
 confidential and intended solely for the use of the individual or 
 entity to whom it is addressed.  The views stated herein do not 
 necessarily represent the view of the company.  If you are not the 
 intended recipient of this e-mail you may not copy, forward, 
 disclose, or otherwise use it or any part of it in any form 
 whatsoever.  If you have received this e-mail in error please 
 e-mail the sender. 
 ** 
 
 
 

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



[PHP] Displaying a money datatype from mssql

2004-04-01 Thread Alex Hogan
How do I correctly display a money datatype from a mssql db?

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

My query is;

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

FROM   orderhistorymaster as om, orderhistorydetail as od

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

ORDER BY om.entrydate

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

Total Amount
5.41108926696E-309

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

But php didn't like that.

In Query Analyzer they come up;
Price
.7500

Total Amount
25.5000

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

alex hogan


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




RE: [PHP] Displaying a money datatype from mssql

2004-04-01 Thread Jay Blanchard
[snip]
My last resort would be to go into the db and do a conversion there but
I
really don't want to do that.
How can I convert these to represent a readable dollar figure?
[/snip]

start with http://www.php.net/number_format

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



RE: [PHP] Displaying a money datatype from mssql

2004-04-01 Thread Alex Hogan
 [snip]
 My last resort would be to go into the db and do a conversion there but
 I
 really don't want to do that.
 How can I convert these to represent a readable dollar figure?
 [/snip]
 
 start with http://www.php.net/number_format

I tried that and it converted the values to 0.00.  I know I'm missing
something simple in the conversion.

alex


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




Re: [PHP] Displaying a money datatype from mssql

2004-04-01 Thread Tom Rogers
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 
AHom.customernumber = '$custnum' and
AHod.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