Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Oracle - extrair timestamp da string varchar?

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.