Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69

    Unanswered: convert varchar or char to float

    Hello,
    Is there a way to convert varchar or char to float?
    Thank you

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    SELECT Convert(float, '1e3')
    -PatP

  3. #3
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69
    Thank you, what is '1e3' and how to apply it my field?

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    1e3 is a float constant. I picked it because it can't be a decimal, money, or any other numeric value, either CHAR or FLOAT and that's it.

    -PatP

  5. #5
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69
    I have a field in my table "SellTo" datatype set to varchar
    value in the field 000021
    how can I convert this field to a float(8)

    Thank you

  6. #6
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69
    Hello,
    I have a query:
    Select
    cast(convert(char, cast (FielsNameas money(8)),1) as money ) as FieldName

    which has to return data in the format like this:.0000
    .0000
    44.0000
    39.0000
    .0000
    169.0000
    .0000
    .0000
    85.0000
    .0000
    288.0000
    .0000
    .0000
    .0000
    36.0000
    36.0000
    36.0000
    294.0000

    What I have is Incorrect:
    .0000
    .0000
    440.0000
    390.0000
    .0000
    .1690.0000
    .0000
    .0000
    850.0000
    .0000
    .2880.0000
    .0000
    .0000
    .0000
    360.0000
    360.0000
    360.0000
    2940.0000

    Please help to solv it.

    Thank you

  7. #7
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Just curious, but what are you really trying to do? You've posted several questions, all of which "miss the mark" in some important way. I think if you back off just a bit from the technical details and focus on the business task at hand and explain that for us, then we can probably give you much better (both easier to implement/understand and more useful) answers.

    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •