SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2008
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing partial data from a string

    I was looking at REPLACE() to do this, but I'm not sure. I have a field called exp_days that shows data like this:

    exp_days
    -----------------
    +31 days
    -102 days
    -10 days
    +25 days

    And I'd like to remove every instance of ' days' including the space before it and keep the positive or neg number. Not sure how to search a string like that, perhaps using LIKE?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Code:
    UPDATE daTable
       SET exp_days = REPLACE(exp_days,' days','')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2008
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfecto! Many thanks.


Bookmarks

Posting Permissions

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