Working with dates and built-in functions EXTRACT : Date Functions « PL SQL Data Types « Oracle PL/SQL Tutorial






EXTRACT function takes a single part of a date/interval/timestamp (year only, month only, and so on, up to the second).

v_nr:= EXTRACT (TYPE from DATE|TIMESTAMP|INTERVAL value);

EXTRACT always returns a numeric value.

If you need the text name of the month, you should use TO_CHAR.

The possible types you can pass into EXTRACT are YEAR, MONTH, DAY, HOUR, MINUTE, and SECOND.

You can also use time zone types with timestamps.

SQL>
SQL> declare
  2      v_nr number;
  3  begin
  4      v_nr:=EXTRACT(MONTH from sysdate);
  5      DBMS_OUTPUT.put_line(v_nr);
  6  end;
  7  /
6

PL/SQL procedure successfully completed.

SQL>








21.10.Date Functions
21.10.1.Working with dates and built-in functions EXTRACT
21.10.2.TRUNC and ROUND
21.10.3.ROUND
21.10.4.ADD_MONTHS
21.10.5.LAST_DAY
21.10.6.MONTHS_BETWEEN
21.10.7.Use TRUNC to get only the time
21.10.8.Returning a point just before a specific midnight with TRUNC
21.10.9.TO_DATE('29-DEC-1988','dd-mon-yyyy')