Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696

    Unanswered: Splitting decimal value

    I need to send an extract to a vendor, and for some reason they want the following:

    999.34 - StrikePrice
    sent as
    999 - StrikeDollar
    34 - StrikeFract

    Tried using various conversions, but at the moment can't solve.

    Thanks.

  2. #2
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Think I got it

    select substring('999.34',1,cast(charindex('.', '999.34') as int)-1)
    select substring('999.34',cast(charindex('.', '999.34') as int)+1, len('999.34'))

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    This can also be done with the FLOOR() function
    Code:
     select FLOOR(StrikePrice) as StrikeDollar,
      StrikePrice - FLOOR(StrikePrice) as StrikeFract

  4. #4
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Quote Originally Posted by MCrowley
    This can also be done with the FLOOR() function
    Code:
     select FLOOR(StrikePrice) as StrikeDollar,
      StrikePrice - FLOOR(StrikePrice) as StrikeFract
    MC, works great, was not aware of this function, many thanks.

  5. #5
    Join Date
    Sep 2003
    Location
    New York, NY
    Posts
    136
    or like this

    SELECT (StrikePrice)%1*100 AS StrikeFract, (StrikePrice) - (StrikePrice)%1 AS StrikeDollar

Posting Permissions

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