I have a table like below. Here the value is string though it has date values
id date_value
1 28-JUL-17
2 20/10/17
3 21-09-2017
4 04-AUG-2017
5 (null)
6 xxxx
Now, I need to update the values of date_value column only if the dates are NOT in the format of dd-MON-yy. Also the values in that column can be null or any other value other than date which should be ignored
Please help.
Sorry, i missed one part. The values which are in format dd-MM-yy should be updated to dd-MON-yy.
So till now I tried
update table_a set value = to_char(to_date(date_value, 'dd-MM-yy'), 'dd-MON-yy')
where date_value is not null
and date_value not like '%/%/%'
and date_value != 'xxxx'
I got SQL Error: ORA-01858 - "a non-numeric character was found where a numeric was expected"
I was able to fix this using below query
update table_a set value = to_char(to_date(date_value, 'dd/MM/yyyy'), 'dd-MON-yy')
where regexp_like (date_value, '[0-9]{2}/[0-9]{2}/[0-9]{4}')