Determine and display years and months : Date Type Convert « PL SQL Data Types « Oracle PL/SQL Tutorial






SQL>
SQL> DECLARE
  2     start_date DATE;
  3     end_date DATE;
  4     service_interval INTERVAL YEAR TO MONTH;
  5     years_of_service NUMBER;
  6     months_of_service NUMBER;
  7  BEGIN
  8     service_interval := (end_date - start_date) YEAR TO MONTH;
  9     DBMS_OUTPUT.PUT_LINE(service_interval);
 10
 11  END;
 12  /

PL/SQL procedure successfully completed.








21.11.Date Type Convert
21.11.1.Use TO_CHAR in PL/SQL
21.11.2.Assign the string to a date variable. The conversion is implicit.
21.11.3.Assign that date variable to another string
21.11.4.Explicit declaration of format mask
21.11.5.Explicit declaration of format mask in where clause
21.11.6.Determine and display years and months