SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2004
    Location
    New Orleans, USA
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting char to int

    Let me preface: 20 year FoxPro junkie

    Need to convert string to int. Tried conv(N,10,10) returned string N

    field jobno (C) 10

    data 'CUST04-125' ..125=sequential job# for CUST in '04

    Need to order on substr(jobno,8,3)

    In FoxPro VAL(SUBSTR(jobno,8,3))

    Is there a similiar function in MySQL or PHP?

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    698
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    cast(substring(jobno from 8 for 3) as integer)

  3. #3
    SitePoint Member
    Join Date
    Jun 2004
    Location
    New Orleans, USA
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cast(substring(jobno,8,3) as unsigned)
    worked great, can even order by year also with
    order by cast(substring(jobno,5,2) as unsigned),cast(substring(jobno,8,3) as unsigned)

    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
  •