I have a string in SQL as
1|208080|"20170815|00:00:00"|"20160615|23:59:59
I just need to fetch the value 20160615
from the select statement in SQL
I have a string in SQL as
1|208080|"20170815|00:00:00"|"20160615|23:59:59
I just need to fetch the value 20160615
from the select statement in SQL
This regular expression handles NULL elements should they exist in the list and grabs only the digits in the 5th pipe-delimited field (the double-quote looks like a typo but you never know). It's flexible so you can get any field you want, just replace the '5' in the call with the field you want.
SQL> with tbl(str) as (
select '1|208080|"20170815|00:00:00"|"20160615|23:59:59'
from dual
)
select regexp_substr(str, '(\d*?)(\||$)', 1, 5, NULL, 1) field5
from tbl;
FIELD5
--------
20160615
SQL>