Oracle Date column cleaning

前端 未结 3 1701
遥遥无期
遥遥无期 2020-12-12 05:07

I have a table1(DueDate varchar2(20)). It has thousands of date data in different format with some bad data like characters.

eg.

YYYYMMDD,
MM/DD/YYY         


        
3条回答
  •  甜味超标
    2020-12-12 05:50

    This answer builds on Justin Cave’s. If you create another column that is a date field you can then do something like the following:

    UPDATE table1 SET DueDate2 = my_to_date(DueDate) 
       WHERE DueDate2 IS NULL AND DueDate IS NOT NULL;
    

    You could then re-run this update after each modification of the date format in the function. You would have to stop when all the dates not converted are invalid dates (such as ‘ABCD’).

提交回复
热议问题