Search code examples
oracledate-arithmetic

How to add 2 dates in Oracle sp?


How can we add two dates in oracle? For example in sql we can do this, " date_1 + date_2 " how can we achieve the same thing in Oracle


Solution

  • Adding two dates together would be meaningless but you can add an interval to a timestamp. For example, to add 1 year and 10 months to a timestamp:

    SELECT SYSDATE + INTERVAL '1-10' YEAR TO MONTH FROM DUAL;
    

    You can also add days to a DATE column using simple arithmetics. For example, you can add 45 days to the current date using:

    SELECT CURRENT_DATE + 45 FROM DUAL;