Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    12

    Unanswered: Added Two Date data type variables

    SQL Server has a "Datetime" datatype and it is possible to add two variables of this data type. How can I perform the similar operation in Oracle and yield similar results.

    For example let data_variable1="April 10, 2004" and date_variable2="April 11, 2004". Now, date_variable1+date_variable2 gives the result as "2108-07-20 00:00:00.000".

    But in Oracle I am not able to add two "Date" datatypes. How can I get this above specified result/behavior in Oracle.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Added Two Date data type variables

    Oracle does not allow adding two dates together because the idea is absurd! In what sense does 2004-04-10 + 2004-04-11 = 2108-07-20 ? Why isn't it equal to 1960-04-23 or 2937-11-12??? Presumably the result you get is an artifact of the way SQL Server happens to store its dates.

    Of course, you can subtract two dates, and get the difference between them in days as a number. Or you can add a number (of days) to a date and get another date in the obvious manner.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    tony, you're right, it does not make a lot of sense

    see this other thread --> http://www.dbforums.com/showthread.php?threadid=992117

    krish_rs, this is why it is generally considered bad etiquette to post the same question in multiple forums, you will get people trying to help in one forum who are not aware of the answers already given in another forum, and this waste's everybody's time
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Mar 2004
    Posts
    12
    Thanks for your response.

    Rudy : I was in a hurry to get an answer to this. Hence tried posting it in both SQL Server and Oracle forums. I'll refrain from doing so from here on.


    Originally posted by r937
    tony, you're right, it does not make a lot of sense

    see this other thread --> http://www.dbforums.com/showthread.php?threadid=992117

    krish_rs, this is why it is generally considered bad etiquette to post the same question in multiple forums, you will get people trying to help in one forum who are not aware of the answers already given in another forum, and this waste's everybody's time

Posting Permissions

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