How to get number of years, months, days between two dates

Here is a query which will return Years, Months and Days concatenated in a column.


SELECT    TRUNC (MONTHS_BETWEEN (:end_date, :start_date) / 12)
       || ' YEARS '
       || MOD (TRUNC (MONTHS_BETWEEN (:end_date, :start_date)), 12)
       || ' MONTHS '
       || (  TO_DATE (:end_date)
           - ADD_MONTHS (:start_date,
                         TRUNC (MONTHS_BETWEEN (:end_date, :start_date))
                        )
          )
       || ' DAYS'
  FROM DUAL;

Leave a comment for any query.





1 comment:

  1. 1xbet korean - The best soccer betting site
    1xbet korean betting website is now offering bets on horse 1xbet racing, rugby and other sports. Find febcasino out how to get deccasino started now.

    ReplyDelete