Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- update tbl set columnA = columnB
- create or replace function is_date (
- P_String in varchar2
- , P_Date_Format in varchar2
- ) return number is
- l_date date;
- begin
- l_date := to_date(P_String, P_Date_Format);
- return 1;
- exception when others then
- return 0;
- end;
- update my_table
- set date_column = to_date(char_column, 'yyyy-mm-dd')
- where is_date(char_column, 'yyyy-mm-dd') = 1
- update my_table
- set date_column = case when is_date(char_column, 'yyyy-mm-dd') = 1
- then to_date(char_column, 'yyyy-mm-dd')
- when is_date(char_column, 'yyyymmdd') = 1
- then to_date(char_column, 'yyyymmdd')
- ...
- snip
- ...
- end
- UPDATE tbl
- SET columnA = DECODE(type, '1', DECODE(INSTR(columnB, '-'), 5, TO_DATE(columnB, 'YYYY-MM-DD'),
- TO_DATE(columnB, 'MM/DD/YYYY')),
- TO_DATE(columnB, 'MMDDYYYY'));
Add Comment
Please, Sign In to add comment