Home » SQL & PL/SQL » SQL & PL/SQL » Find time difference
Find time difference [message #265423] Thu, 06 September 2007 05:24 Go to next message
kumarn
Messages: 13
Registered: June 2007
Location: London
Junior Member
Hi,

I want to find the time difference in sec between two dates.

e.g
date1 = 9/4/2007 10:22:56 AM
date2 = 9/4/2007 10:26:05 AM
time_diff = 189 secs

Is there any way to get the time_diff value in SQL?



Thanks
Kumarn
Re: Find time difference [message #265426 is a reply to message #265423] Thu, 06 September 2007 05:31 Go to previous messageGo to next message
Soumen Kamilya
Messages: 128
Registered: August 2007
Location: Kolkata
Senior Member

Check that:
select (to_date('9/4/2007 10:26:05 AM','mm/dd/yyyy hh:mi:ss PM')-
to_date('9/4/2007 10:22:56 AM','mm/dd/yyyy hh:mi:ss PM'))*24*60*60  from dual;


Cheers
Soumen
Re: Find time difference [message #265427 is a reply to message #265423] Thu, 06 September 2007 05:31 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

select (date-date2)*24*60*60 from tablename;
Re: Find time difference [message #265458 is a reply to message #265423] Thu, 06 September 2007 06:32 Go to previous message
kumarn
Messages: 13
Registered: June 2007
Location: London
Junior Member
Thanks everyone.
Previous Topic: better way of string parsing?
Next Topic: Cursor operation, checking return result
Goto Forum:
  


Current Time: Thu Dec 08 10:46:26 CST 2016

Total time taken to generate the page: 0.07316 seconds