Results 1 to 3 of 3

Thread: Calculate difference between two dates

  1. #1
    Geek_Guest
    Guest

    Calculate difference between two dates

    I have a table with column date. This column stores the date and time stamp of the transaction. How do I calculate the difference between two dates for the same type of transaction in terms of days/time?

    Suppose the table is TRANSACTION and the data is as follows:
    TRANSACTION_TYPE DATE (in MM/DD/YYYY HH:MI:SS AM format)
    ------------------------ ------
    1 09/01/2007 10:45:19 AM
    1 09/27/2007 08:27:15 PM
    1 09/27/2007 10:11:17 PM

    Question asked by visitor priyanka


  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Calculate difference between two dates

    try to use simple substraction

    select date1-date2 from dual;


  3. #3
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Calculate difference between two dates

    SELECT TO_DATE(TO_CHAR(Date1,'MM/DD/YYYY HH:MI:SS AM'),'MM/DD/YYYY HH:MI:SS AM')-TO_DATE(TO_CHAR(Date2,'MM/DD/YYYY HH:MI:SS AM'),'MM/DD/YYYY HH:MI:SS AM') FROM TABLENAME;
    TRY THIS....


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact