Reputation: 39
I want to know the datatype
of below code.... number
or date
?
select round(24*(sysdate - to_date('18-09-18 06:30','YYYY-MM-DD HH24 Mi'))) as Hours_Diff
from Dual;
Upvotes: 1
Views: 30
Reputation: 167822
[TL;DR] Subtracting one DATE
from another gives the number of days difference as a number. Multiplying by 24 and rounding it does not change the data type.
(and subtracting one TIMESTAMP
from another give the difference as a INTERVAL DAY TO SECOND
data type)
Longer answer:
SELECT DUMP( round(24*(sysdate - to_date('18-09-18 06:30','YYYY-MM-DD HH24 Mi'))) )
FROM DUAL
(Note: to_date('18-09-18 06:30','YYYY-MM-DD HH24 Mi')
will give a year of 0018
not 2018
!)
Outputs:
Typ=2, Len=5: 196, 18, 53, 30, 33
Upvotes: 2