MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL 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 Dev Shed Forums Sponsor:
  #1  
Old October 4th, 2000, 09:08 PM
hanumani hanumani is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: wendell, mass, USA
Posts: 87 hanumani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 18 sec
Reputation Power: 9
how do I trim zeros off a double type field in mysql i.e. .2000 -> .2 and 2.2000 -> 2.2 and 2.222 -> 2.222 and 0.003450 -> 0.003450.

Thanx for the help
Jacob Singh

Reply With Quote
  #2  
Old October 4th, 2000, 10:43 PM
billyo billyo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 114 billyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
FORMAT(X,D)
Formats the number x to a string with d decimals to a format like "nn,nnn.nnn". If d is 0, the result has no decimal point or fractional part.

eg,

SELECT FORMAT(double_numbers,2) AS rounded FROM tbl_name;

I let SepodatiCreations tell you where I found that.


[This message has been edited by billyo (edited October 04, 2000).]

Reply With Quote
  #3  
Old October 5th, 2000, 04:31 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,381 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 7 h 28 m 9 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
A little birdie told you??

I don't think that solves his problem, though. That makes it a fixed number of decimal places, rather than just taking off the zeros.

I'm not sure how to get rid of the zeros right as you select it out of the datbase. If you're using PHP, you could write a little routine that strips them off....

---John Holmes...

------------------
*************************************************************
* The manual can probably answer 90% of your questions... *
* *
* PHP Manual. www.php.net/manual *
* MySQL Manual: www.mysql.com/documentation/mysql/bychapter *
*************************************************************

Reply With Quote
  #4  
Old October 5th, 2000, 10:42 AM
hanumani hanumani is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: wendell, mass, USA
Posts: 87 hanumani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 18 sec
Reputation Power: 9
yeah, thats what I thought, if you have the time to respond, could you send me an example of what the code would look like. I looked around in the php manual, but I'm a little shaky on string expressions
thanx
J

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > how do I trim zeros off a double type field in mysql


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 4 hosted by Hostway