Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Below is my Query :
Quote:
Select a.Sent, b.Recd, ((b.Recd-a.Sent)*1440) DIFF
from TableA b, TableB a
where b.type = 'AAA'
and b.ID = a.ID1


Where ID and ID1 are foreign Key
Both sent, Recd dates are in format like '
Quote:
5/9/2011 5:22:00 PM
'

But i am not getting :
Quote:
((b.Recd-a.Sent)*1440)
in minutes
Instead i am getting like
Quote:
-000000000 06:48:00



I need the difference of DATE in Minutes only.

Please suggest.
Posted
Updated 4-Feb-13 5:44am
v2

VB
SELECT
trunc(DATE1-DATE2) days,
mod( trunc( ( DATE1-DATE2 ) * 24 ), 24) HOURS,
mod( trunc( ( DATE1-DATE2 ) * 1440 ), 60 ) MINUTES,
mod( trunc( ( DATE1-DATE2 ) * 86400 ), 60 ) SECONDS
FROM dual;

change as per ur table

check out this link
http://stackoverflow.com/questions/206222/oracle-best-select-statement-for-getting-the-difference-in-minutes-between-two[^]
 
Share this answer
 
Comments
Nibin22 4-Feb-13 23:39pm    
It is Working !!! Thanks :)
This should do it:
SQL
select
  round((second_date - first_date) * 1440,2)
You need to round the value.
 
Share this answer
 
Comments
Nibin22 4-Feb-13 23:39pm    
It is Working !!! Thanks :)
I suggest that you try using the NUMTODSINTERVAL[^] function with the second parameter of 'MINUTE'.

NUMTODSINTERVAL(b.recd - a.sent, 'MINUTE')
 
Share this answer
 
Comments
Nibin22 4-Feb-13 23:39pm    
It is Working !!! Thanks :)
Thanks Friends,

I figured like below :

SQL
Select a.Sent, b.Recd, (Extract Minute from b.Recd-a.Sent) DIFF
  from TableA a, TableB b
 where b.type = 'AAA'
   and b.ID = a.ID1;



Where " (Extract Minute from b.Recd-a.Sent) DIFF" returns the date difference in MINUTES
 
Share this answer
 
Comments
Nibin22 4-Feb-13 23:38pm    
Nice!!! I didnt imagine this number of solutions will be there to find the date difference!!!

Thanks a lot Guys !!!! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900