Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Unanswered: Elapsed Days as Years, Months and Days

    I know how to track the duration of time lapsed between two date using Excel that one has to use the DATEDIF worksheet function, but I got no clue on how to it in Oracle. This is how far I go.

    SELECT LAST_NAME, TRUNC((SYSDATE - HIRE_DATE)/365)
    AS "Years",
    TRUNC((SYSDATE - HIRE_DATE)/12)
    AS "Months"
    FROM EMPLOYEES
    ORDER BY "Years" DESC;

    Any one with a clue?

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Code:
    SELECT LAST_NAME, months_between(tRUNC(SYSDATE ),HIRE_DATE)/12 "Years",
     months_between(tRUNC(SYSDATE ),HIRE_DATE) "Months"
    FROM EMPLOYEES
    ORDER BY 2 DESC;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •