Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

cara mengekstrak format tanggal dari oracle string

SELECT set_act_id_1,
       TO_DATE( REGEXP_SUBSTR( set_act_id_1, '[^+]+', 1, 6 ), 'DD-MM-YYYY' )
FROM   STAGE.CUSTOMERS 
WHERE  set_act_id_1 is not null

Atau

SELECT set_act_id_1,
       TO_DATE( SUBSTR( set_act_id_1, INSTR( set_act_id_1, '+', 1, 5 ) + 1 ), 'DD-MM-YYYY' )
FROM   STAGE.CUSTOMERS 
WHERE  set_act_id_1 is not null

Perbarui :

SELECT CASE
         WHEN REGEXP_LIKE( expiry_date, '^\d{1,2}[ \/-](JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)[ \/-]\d{4}$', 'i' )
         THEN TO_DATE( expiry_date, 'dd mon yyyy' )
         WHEN REGEXP_LIKE( expiry_date, '^\d{1,2}[ \/-](JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)[ \/-]\d{2}$', 'i' )
         THEN TO_DATE( expiry_date, 'dd mon yy' )
         WHEN REGEXP_LIKE( expiry_date, '^(0?[1-9]|[12]\d|3[01])[ \/-](0?[1-9]|1[0-2])[ \/-]\d{4}$' )
         THEN TO_DATE( expiry_date, 'dd mm yyyy' )
         WHEN REGEXP_LIKE( expiry_date, '^(0?[1-9]|1[0-2])[ \/-](0?[1-9]|[12]\d|3[01])[ \/-]\d{4}$' )
         THEN TO_DATE( expiry_date, 'mm dd yyyy' )
         WHEN REGEXP_LIKE( expiry_date, '^(0?[1-9]|[12]\d|3[01])[ \/-](0?[1-9]|1[0-2])[ \/-]\d{2}$' )
         THEN TO_DATE( expiry_date, 'dd mm yy' )
         WHEN REGEXP_LIKE( expiry_date, '^(0?[1-9]|1[0-2])[ \/-](0?[1-9]|[12]\d|3[01])[ \/-]\d{2}$' )
         THEN TO_DATE( expiry_date, 'mm dd yy' )
         ELSE NULL
       END AS expiry_date
FROM   (
  SELECT set_act_id_1,
         SUBSTR( set_act_id_1, INSTR( set_act_id_1, '+', 1, 5 ) + 1 ) As expiry_date
  FROM   STAGE.CUSTOMERS 
  WHERE  set_act_id_1 is not null
)



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Permintaan RODBC tidak mengembalikan data

  2. Perubahan Antarmuka Oracle

  3. DPI-1047:Perpustakaan Klien Oracle 64-bit tidak dapat dimuat

  4. Apakah ada cara untuk menggunakan RSA di Oracle/PL SQL?

  5. Tidak ada acara onMessage di Runtime (Java JMS MessageListener di Oracle Queue)