-2

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

APC
  • 144,005
  • 19
  • 170
  • 281
Pinchas K
  • 1,541
  • 3
  • 13
  • 19
  • 2
    How do you define the sum of two date? What should one expect from `'1999-12-31' + '2012-10-18'`? – ypercubeᵀᴹ Oct 18 '12 at 12:44
  • 1
    What `sql` are you referring to? Adding two dates is meaningless. You can add an interval to a date. – Alex Oct 18 '12 at 12:44
  • What the result you want by summing 2 dates? – Marc Oct 18 '12 at 12:44
  • Which is the expected result when adding two dates? How would you add dates? – GuiGi Oct 18 '12 at 12:45
  • the right way is to convert 1 date into number but when i convert date into number i see an other exception in oracle query – Pinchas K Oct 18 '12 at 12:55
  • What would the number mean? Like I said, you need an interval, not a date. Is the number a number of days? Months? Years? Seconds? – Alex Oct 18 '12 at 13:00
  • As several people have said, your question is meaningless. Yet you persistently refuse to explain what is you are trying to achieve. Voting to close. – APC Oct 18 '12 at 13:20

1 Answers1

3

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;
Srini V
  • 11,045
  • 14
  • 66
  • 89
Alex
  • 7,728
  • 3
  • 35
  • 62