Convert to date several possible masks in Oracle

It so happened that I should get the date from the varchar2 column in oracle, but it is incompatible in formatting. Some fields may have "2009.12.31", others - 2009/12/32 00:00:00. Is there any standard design I could use, so I don't have to go through

begin
  to_date(date, mask1)
exception
  begin
    to_date(date,mask2)
  exception
    ..
  end
end

blocks or string analysis of a preceding date to determine the correct mask? Something like to_date(date, mask1,mask2,..)?

+3
source share
2 answers

No, but some Oracle date formats are forgiving differences, for example.

SQL> select to_date('2009.12.31','YYYY/MM/DD') from dual;

TO_DATE('20
-----------
31-DEC-2009

, , . , , , .

+4

, , - , (, "10-11-2009" 10 11 ?), .

, , (, "DD-MON-YYYY HH24: MI: SS" "31 -DEC-2009" 10:30:00 ', '31/deC/2009 10:30', '31 dec 2009 ').

BEGIN (format1) , , (format2) , , ....

+1

Source: https://habr.com/ru/post/1726058/


All Articles