I have a table as follows:
Filename - varchar
Creation Date - Date format dd/mm/yyyy hh24:mi:ss
Oldest cdr date - Date format dd/mm/yyyy hh24:mi:ss
How can I calcuate the difference in hours minutes and seconds (and possibly days) between the two dates in Oracle SQL?
Thanks
To get result in seconds:
Check [https://community.oracle.com/thread/2145099?tstart=0][1]
You can substract dates in Oracle. This will give you the difference in days. Multiply by 24 to get hours, and so on.
If your date is stored as character data, you have to convert it to a date type first.
Note:
This answer applies to dates represented by the Oracle data type
DATE
. Oracle also has a data typeTIMESTAMP
, which can also represent a date (with time). If you subtractTIMESTAMP
values, you get anINTERVAL
; to extract numeric values, use theEXTRACT
function.