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
[b]Question asked by visitor priyanka[/b]
Re: Calculate difference between two dates
try to use simple substraction
[B]select date1-date2 from dual;[/B]
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....