Time difference between two timestamps in Apex
Subtracting two date values in Oracle results in number of DAYS. Therefore, you'd have to do some math in order to get hours (or minutes). Here's an example:
col diff_days format 90D00000
col diff_hours format 90D00000
col diff_minutes format 90D00000
with test as (select to_date('29.12.2017 16:05', 'dd.mm.yyyy hh24:mi') d_order,
to_date('29.12.2017 16:39', 'dd.mm.yyyy hh24:mi') d_now
from dual)
select
d_now - d_order diff_days,
(d_now - d_order) * 24 diff_hours,
(d_now - d_Order) * (24 * 60) diff_minutes
from test;
OUTPUT
DIFF_DAYS DIFF_HOURS DIFF_MINUTES
--------- ---------- ------------
0,02361 0,56667 34,00000
Comments
Post a Comment