Add 2 months to current timestamp

前端 未结 5 1577
星月不相逢
星月不相逢 2020-12-11 21:23

How can I add months to a timestamp value in Oracle? In my query, it\'s getting converted to date value instead:

     SELECT add_months(current_timestamp,2)          


        
5条回答
  •  情书的邮戳
    2020-12-11 22:13

    SELECT current_timestamp + INTERVAL '2' MONTH from dual;
    

    To display this in your desired format, use TO_CHAR:

    SELECT TO_CHAR(current_timestamp + INTERVAL '2' MONTH, 
           'YYYY-MM-DD HH24:MI:SS.FF9TZH:TZM') from dual;
    2013-03-11 23:58:14.789501000+01:00
    

提交回复
热议问题