我想在我的表中爲ORACLE刪除過去6個月的所有記錄。刪除過去6個月的記錄Oracle
我現在有
delete from table t
where to_date(substr(t.DATE_SENT,1,10),'MM/DD/YYYY') < add_months(trunc(sysdate), -6);
此表中的字符串格式爲'12/21/2015 12:00:00 AM'
。
注意我明白,這應該是一個DATETIME而不是一個varchar2,但它恰好是一個varchar2,所以我現在試圖找到一個工作。
該查詢似乎有點爲SELECT *工作,但然後用SQL
Error: ORA-01830: date format picture ends before converting entire input string
任何幫助,將不勝感激崩潰。
我猜你有價值謊言1/1/2015在數據中。 –
嘗試查找日期格式與'select * from table where not regexp_like(date_sent,'^ [[:digit:]] {1,2}/[[:digit:]] {1, 2}/[[:數字:]] {4}「)'。 –