#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    wendell, mass, USA
    Posts
    87
    Rep Power
    15
    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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    15
    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).]
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    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 *
    *************************************************************
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    wendell, mass, USA
    Posts
    87
    Rep Power
    15
    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

Similar Threads

  1. Regular expression (?) in a mysql field
    By acp in forum PHP Development
    Replies: 5
    Last Post: February 6th, 2004, 11:09 AM
  2. Replies: 1
    Last Post: February 6th, 2004, 06:53 AM
  3. Replies: 3
    Last Post: January 31st, 2004, 01:16 AM
  4. database type: mySQL, MS SQL and Access
    By vinyl in forum ColdFusion Development
    Replies: 5
    Last Post: January 27th, 2004, 08:25 PM
  5. MySQL and field length ?!!?
    By oobiExtant in forum MySQL Help
    Replies: 3
    Last Post: January 25th, 2004, 11:47 AM

IMN logo majestic logo threadwatch logo seochat tools logo