Oracle时间戳到sysdate转换错误

时间:2012-04-20 19:20:08

标签: oracle10g

它给出了这样的错误:日期格式图片在转换整个输入字符串之前结束

declare
  v_t timestamp; 
begin
  v_t := to_timestamp(systimestamp,'DD/MM/YY')+interval '12-3' year to month;
  DBMS_OUTPUT.PUT_LINE(v_t);
end;

1 个答案:

答案 0 :(得分:1)

SYSTIMESTAMP已经是时间戳,因此您不想致电to_timestamp。如果您想将12年3个月添加到当前时间戳

SQL> ed
Wrote file afiedt.buf

  1  declare
  2    v_t timestamp;
  3  begin
  4    v_t := systimestamp +interval '12-3' year to month;
  5    DBMS_OUTPUT.PUT_LINE(v_t);
  6* end;
SQL> /
20-JUL-24 03.27.28.966000 PM

PL/SQL procedure successfully completed.