往oracle中插入时间 '2007-12-28 10:07:24'
如果直接按照字符串方式,或者,直接使用to_date('2007-12-28 10:07:24'),没有指定日期格式,就会报错:ORA-01861: 文字与格式字符串不匹配
必须指定日期格式
to_date('2007-12-28 10:07:24' , 'yyyy-mm-dd hh24:mi:ss')
/* Formatted on 2019/10/10 09:17:55 (QP5 v5.252.13127.32847) */ SELECT TO_CHAR (TO_DATE ('2019-10-10', 'yyyy-mm-dd'), 'YY') || (CASE WHEN TO_CHAR ( NEXT_DAY (TO_DATE ('2019-10-10', 'yyyy-mm-dd'), '星期日'), 'YYYY') <> TO_CHAR (TO_DATE ('2019-10-10', 'yyyy-mm-dd'), 'YYYY') THEN '01' WHEN TO_CHAR (TO_DATE ('2019-10-10', 'yyyy-mm-dd'), 'D') = '1' THEN TO_CHAR (TO_DATE ('2019-10-10', 'yyyy-mm-dd') + 1, 'IW') ELSE TO_CHAR (TO_DATE ('2019-10-10', 'yyyy-mm-dd'), 'IW') END) AS YearWeek FROM DUAL