SQL Error in SQL exprsssion using a SUBSTRING

SOLVED

Parents
  • +1
    verified answer

    Use the convention of table.field in place of where you have the field CONTRACT and take out the SELECT & the FROM PMTRAN. It should look like below. However, it be might easier to just to use the field FMTCONTNO, since that is the formatted contract number so it usually has the dashes already in place for most companies.

    SUBSTRING(PMTRAN.CONTRACT,1,3)+'-'+SUBSTRING(PMTRAN.CONTRACT,4,3)+'-'+SUBSTRING(PMTRAN.CONTRACT,7,2)+'-'+SUBSTRING(PMTRAN.CONTRACT,9,3)+'-'+SUBSTRING(PMTRAN.CONTRACT,12,4)

  • 0 in reply to Gabriela Yates

    Thank you, you will note that the number of characters being split up is 15 and the max for a Contract number is 16 including dashes.  So that is 19 in total.  So what the client wants will not work and I was looking for an alternative.  I will try  your string and see if that works.

Reply Children