-
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
-
Re: Calculate difference between two dates
try to use simple substraction
select date1-date2 from dual;
-
Expert Member
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
-
Forum Rules