ZEE
ZEE

Reputation: 391

sql date difference

I am using oracle 10g

I need to get the difference between two dates in the format of to_char(‘HH24:MI’).

I tried to apply :

Select to_char(FRM_TIME-HOURS_IN,'HH24:MI') FROM Time_Test 

but it gave me invalid number format.

Can you please help.

Upvotes: 2

Views: 459

Answers (3)

Jeffrey Kemp
Jeffrey Kemp

Reputation: 60262

This is what I'd use:

select to_char(DATE '2000-01-01' + (FRM_TIME-HOURS_IN),'HH24:MI') FROM Time_Test

Upvotes: 2

Himanshu
Himanshu

Reputation: 32602

Try this:

SELECT HOURS_IN
, FRM_TIME
, (24 * extract(day from (FRM_TIME- HOURS_IN) day(9) to second))
+ extract(hour from (FRM_TIME- HOURS_IN) day(9) to second)
+ ((1/100) * extract(minute from (FRM_TIME- HOURS_IN) day(9) to second)) as "HOUR.MINUTE"
* from t

Upvotes: 0

Ram Singh
Ram Singh

Reputation: 6918

try to use

datediff() to get Date diff.

Upvotes: 0

Related Questions