Total Pageviews

March 17, 2016

3/17/2016 04:45:00 AM
Extraction of year,month.day from date  function by using Extract

Syntax:
SELECT   EXTRACT (YEAR FROM SYSDATE) AS year,
         EXTRACT (MONTH FROM SYSDATE) AS month,
         EXTRACT (DAY FROM SYSDATE) AS day
  FROM   DUAL

You can also achieve this by using


SELECT   TO_CHAR (SYSDATE, 'YEAR') AS YEAR,
         TO_CHAR (SYSDATE, 'MONTH') AS MONTH,
         TO_CHAR (SYSDATE, 'DAY') AS DAY
  FROM   DUAL

Advantages of Extract function:

  It is easy  to get date,day,year from Date functions

Dis advantages:

we can't get  MON-YYYY AS we get in to_char function