Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    105

    Unanswered: SQL get first character of a string

    Is there a function in SQL that will find the first character of a character string?

    Select Org from PR where id = '100'

    Normally, Org will retuen a string such as '1:00'. But, all I want from this string is the first character, '1'.

    Thank You

  2. #2
    Join Date
    May 2004
    Posts
    105
    I figured it out.

    SUBSTRING(Org, 1, LEN(Org) - 3)

    Thanks.

  3. #3
    Join Date
    Jul 2002
    Posts
    58
    A simpler way is LEFT(Org,1)

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    So you want to return the same value when Org = '1:00' as when Org = '10:00', '11:00', or '12:00'?

    I hope these aren't time values you are dealing with...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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