Use to_yminterval in PL/SQL : TO_YMINTERVAL « Date Timezone « Oracle PL / SQL






Use to_yminterval in PL/SQL

 
SQL>
SQL>
SQL>  declare
  2      l_hiredate timestamp := to_timestamp('1996-11-04 07:00:00','YYYY-MM-DD HH24:MI:SS');
  3      l_oneyr    interval year to month := to_yminterval('01-00');
  4      l_18mos    interval year to month := to_yminterval('01-06');
  5      l_threeyrs interval year to month := to_yminterval('03-00');
  6      l_fiveyrs  interval year to month := to_yminterval('05-00');
  7    begin
  8      dbms_output.put_line('One Year: '||(l_hiredate + l_oneyr));
  9      dbms_output.put_line('One + 1/2 Year: '||(l_hiredate + l_oneyr));
 10      dbms_output.put_line('Three Years: '||(l_hiredate + l_threeyrs));
 11      dbms_output.put_line('Five Years: '||(l_hiredate + l_fiveyrs));
 12    end;
 13    /
One Year: 04-NOV-97 07.00.00.000000000 AM
One + 1/2 Year: 04-NOV-97 07.00.00.000000000 AM
Three Years: 04-NOV-99 07.00.00.000000000 AM
Five Years: 04-NOV-01 07.00.00.000000000 AM

PL/SQL procedure successfully completed.

SQL>
SQL> --

 








Related examples in the same category

1.TO_YMINTERVAL(x): Converts the string x to an INTERVAL YEAR TO MONTH
2.Date + to_yminterval('01-05')
3.to_yminterval('00-01')
4.to_yminterval('01-05')