Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datediff in Oracle SQL?

Status
Not open for further replies.

kunzi

Technical User
Nov 24, 2009
5
US
Suppose I have two SQL expressions now:

1. exp1

select date_1
from table_1
where blah blah

2. exp2

Select date_2
from table_2
where blah blah

How can I get the date difference in hours between the two dates returned above? I guess simply exp1-exp2 won't work...

Thanks!
 


hi,

how are the two tables logically related?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Table_1 left outer joins Table_2.
 



post your outer join sql please, with the two dates.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
You should be able to just use a formula:

datediff("n",{%exp1},{%exp2})

...where {%exp2} is the more recent date.

-LB
 
For hours, that should have been:

datediff("h",{%exp1},{%exp2})

"n" is for minutes (to distinguish it from "m" for months.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top