1

I have string linke this:

'Podlaski Oddział Straży Granicznej 
Informacja dobowa o zdarzeniach na terenie województwa podlaskiego 
w dniu 15.04.2013 r.'

I need extract date from this string: day: 15, month:4, year: 2013 and put retrieved info into timestamp(6), something like this:

to_timestamp(v_string)

.. where v_string is retrieved value (in this case '13/04/15')

What is the best way to do this with regex, to get '13/04/15' as result in this example?

user1209216
  • 7,404
  • 12
  • 60
  • 123

1 Answers1

2
SQL> alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SSXFF';

Session altered.

SQL> with t as (
  2     select 'Podlaski Oddział Straży Granicznej
  3  Informacja dobowa o zdarzeniach na terenie województwa podlaskiego
  4  w dniu 15.04.2013 r.'
  5         as original_string
  6       from dual)
  7  select to_timestamp(regexp_substr(original_string, '\d\d\.\d\d\.\d\d\d\d'), 'DD.MM.YYYY') as the_timestamp
  8    from t;

THE_TIMESTAMP
---------------------------------------------------------------------------
2013-04-15 00:00:00,000000000

1 row selected.
Marco Baldelli
  • 3,638
  • 1
  • 22
  • 29