Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old August 22nd, 2002, 06:47 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Yikes! SQL Money Formatting - Where's the Comma?

Hi, I'm using SQl Server 2000 and I have some data stored in MONEY format that I'd like to display via an XML web report. While the data itself comes up properly, itmis not formatted with commas separating the millions, thousands, and hundreds. MSDN says that this formatting is based on regional settings. My settings are:
- SERVER: Reginal Settings set to US English, with all desired number formatting
- CLIENT: Reginal Settings set to US English, with all desired number formatting. ODBC settings have option "Use regional settings to display numbers, dates, etc." checked.

Why do I still not get my precious commas? Is there a way to override this?

Thanks!

Reply With Quote
  #2  
Old September 16th, 2002, 03:09 PM
blazin blazin is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Aurora, CO, USA
Posts: 24 blazin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to blazin Send a message via AIM to blazin
RE: Yikes! SQL Money Formatting - Where's the Comma?

I think what you need to take a look at is PHP's number_format function.
http://www.php.net/manual/en/function.number-format.php

Basically what you'll probably want to do is take your money data (I'll call it $money), and run it through the function something like:
php Code:
Original - php Code
  1.  
  2. $money = number_format($money, 2, '.', ',');

The 2 tells the function how many numbers after the decimal, the . is the decimal separator, and the , is the thousands seperator.

Hope this helps.

Dave

Reply With Quote
  #3  
Old September 16th, 2002, 04:00 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Yikes! SQL Money Formatting - Where's the Comma?

You can use the convert function on the money data type and have it use regional options...this assumes a column of amount and a table called test.


select convert(varchar(12),amount,1) from test

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Yikes! SQL Money Formatting - Where's the Comma?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway