FMiS Help Desk
FMiS Help Desk

Reputation: 75

How to read string from right PLSQL

In a table column, I have this value:

DV-2011-01-000004 (the data type is varchar2)

How can i get the part of the string '000004'? In t-sql they have this right() function but in PL SQL i cant'seem to find a function just like the right() in t-sql.

Thanks for the help.

Upvotes: 5

Views: 14457

Answers (2)

Dor Cohen
Dor Cohen

Reputation: 17080

you can use:

 SUBSTR('DV-2011-01-000004', INSTR('DV-2011-01-000004', '-', -1) +1)

when using INSTR with negative start position he will find the last index of "-". then SUBSTR will cut from this occurrence until the end (because I didn't supply Length)

Upvotes: 2

turbanoff
turbanoff

Reputation: 2479

substr('DV-2011-01-000004', length('DV-2011-01-000004')-6 + 1 )

Upvotes: 8

Related Questions